Skip to content
This repository has been archived by the owner on Nov 24, 2020. It is now read-only.

Fix for the JSON decode error. #20

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions bin/converter.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
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
2 changes: 1 addition & 1 deletion src/H2P/Converter/PhantomJS.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 . '"');
Expand Down