diff --git a/bin/converter.js b/bin/converter.js index 163ebc0..9f1ddfb 100755 --- a/bin/converter.js +++ b/bin/converter.js @@ -48,8 +48,9 @@ try { throw 'You must pass the URI and the Destination param!'; } - // Take all options in one JSON param - var options = JSON.parse(args[1]); + // Decode the provided base64 encoded string then parse it as JSON to use as our parameters. + var decoded_base64 = atob(args[1]), + options = JSON.parse(decoded_base64); page.customHeaders = options.request.headers; phantom.cookies = options.request.cookies; diff --git a/src/H2P/Converter/ConverterAbstract.php b/src/H2P/Converter/ConverterAbstract.php index 4bf18da..fad721b 100755 --- a/src/H2P/Converter/ConverterAbstract.php +++ b/src/H2P/Converter/ConverterAbstract.php @@ -116,7 +116,7 @@ public function convert($origin, $destination) { if (!$origin instanceof Request) { if ($origin instanceof TempFile) { - $origin = 'file://' . $origin->getFileName(); + $origin = 'file:///' . $origin->getFileName(); } // Create a simple GET request URI diff --git a/src/H2P/Converter/PhantomJS.php b/src/H2P/Converter/PhantomJS.php index afaa396..146bfb7 100644 --- a/src/H2P/Converter/PhantomJS.php +++ b/src/H2P/Converter/PhantomJS.php @@ -277,7 +277,7 @@ protected function transform(Request $origin, $destination) 'request' => $request, ) + $this->options; - $result = json_decode(trim(shell_exec($this->getBinPath() . ' ' . escapeshellarg(json_encode($args))))); + $result = json_decode(trim(shell_exec($this->getBinPath() . ' ' . escapeshellarg(base64_encode(json_encode($args)))))); if (!$result->success) { throw new Exception('Error while executing PhantomJS: "' . $result->response . '"');