From 551953da4fe9a9b3ef537316c03521fee04f17c3 Mon Sep 17 00:00:00 2001 From: demeritcowboy Date: Mon, 21 Sep 2020 19:22:39 -0400 Subject: [PATCH 1/3] Don't crash on windows Windows doesn't like the multiline command. --- src/Subscriber/PhpSubscriber.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/Subscriber/PhpSubscriber.php b/src/Subscriber/PhpSubscriber.php index ac0d536..d283212 100644 --- a/src/Subscriber/PhpSubscriber.php +++ b/src/Subscriber/PhpSubscriber.php @@ -47,6 +47,9 @@ public static function runTask(CompileTaskEvent $event) var_export($event->getTask()->definition, 1) )); + // Don't crash on windows + $cmd = str_replace("\n", " ", $cmd); + $r = new ShellRunner($event->getComposer(), $event->getIO()); $r->run($cmd); } From 90990bfd17ecb3ce761a32a51e8f12c16ce26f4a Mon Sep 17 00:00:00 2001 From: Tim Otten Date: Mon, 21 Sep 2020 18:18:17 -0700 Subject: [PATCH 2/3] PhpSubscriber - When delegating to subprocess, escape non-alpha characters more aggressively. --- src/Subscriber/PhpSubscriber.php | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/Subscriber/PhpSubscriber.php b/src/Subscriber/PhpSubscriber.php index d283212..e9fe4ba 100644 --- a/src/Subscriber/PhpSubscriber.php +++ b/src/Subscriber/PhpSubscriber.php @@ -41,14 +41,11 @@ public static function runTask(CompileTaskEvent $event) throw new \RuntimeException("CompilePlugin: Failed to locate autoload.php"); } $cmd = '@php -r ' . escapeshellarg(sprintf( - 'require_once %s; %s(%s);', + 'require_once %s; %s(json_decode(base64_decode(%s), 1));', var_export($autoload, 1), $event->getTask()->definition['php-method'], - var_export($event->getTask()->definition, 1) + var_export(base64_encode(json_encode($event->getTask()->definition)), 1) )); - - // Don't crash on windows - $cmd = str_replace("\n", " ", $cmd); $r = new ShellRunner($event->getComposer(), $event->getIO()); $r->run($cmd); From 45382dc1a9dd1ede88d66700050307acb526410d Mon Sep 17 00:00:00 2001 From: Tim Otten Date: Mon, 21 Sep 2020 18:45:15 -0700 Subject: [PATCH 3/3] (NFC) Cleanup whitespace --- src/Subscriber/PhpSubscriber.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Subscriber/PhpSubscriber.php b/src/Subscriber/PhpSubscriber.php index e9fe4ba..22c3ffd 100644 --- a/src/Subscriber/PhpSubscriber.php +++ b/src/Subscriber/PhpSubscriber.php @@ -46,7 +46,7 @@ public static function runTask(CompileTaskEvent $event) $event->getTask()->definition['php-method'], var_export(base64_encode(json_encode($event->getTask()->definition)), 1) )); - + $r = new ShellRunner($event->getComposer(), $event->getIO()); $r->run($cmd); }