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

Pull request from https://github.com/kriansa/h2p/pull/20 #2

Merged
merged 1 commit into from
Apr 9, 2021
Merged
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
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