Skip to content
This repository has been archived by the owner on Dec 8, 2023. It is now read-only.

Commit

Permalink
Merge pull request #2 from Recras/json-decode-error
Browse files Browse the repository at this point in the history
Pull request from kriansa#20
  • Loading branch information
timmipetit authored Apr 9, 2021
2 parents 91575ab + 0c64a6b commit 3eeec7d
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
4 changes: 3 additions & 1 deletion bin/converter.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,9 @@ try {
}

// 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;
page.settings.dpi = 96;
Expand Down
2 changes: 1 addition & 1 deletion src/H2P/Converter/ConverterAbstract.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 3 additions & 1 deletion src/H2P/Converter/PhantomJS.php
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,9 @@ 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 . '"');
Expand Down

0 comments on commit 3eeec7d

Please sign in to comment.