Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update AbstractGenerator.php #470

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
8 changes: 4 additions & 4 deletions src/Knp/Snappy/AbstractGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -536,21 +536,21 @@ protected function buildCommand($binary, $input, $output, array $options = [])
} elseif (\is_array($option)) {
if ($this->isAssociativeArray($option)) {
foreach ($option as $k => $v) {
$command .= ' --' . $key . ' ' . \escapeshellarg($k) . ' ' . \escapeshellarg($v);
$command .= ' --' . $key . ' ' . \escapeshellarg($k) . ' ' . \escapeshellarg($v ?? '');
}
} else {
foreach ($option as $v) {
$command .= ' --' . $key . ' ' . \escapeshellarg($v);
$command .= ' --' . $key . ' ' . \escapeshellarg($v ?? '');
Comment on lines -539 to +543
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I need to double check on the wkhtmltopdf options but, IMHO, we should simply skip invalid array entries.
I think we should skip options with key/value that are not valid strings.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm saying to skip it as it's the current behavior for null/false options.

}
}
} else {
// Dont't add '--' if option is "cover" or "toc".
if (\in_array($key, ['toc', 'cover'])) {
$command .= ' ' . $key . ' ' . \escapeshellarg($option);
$command .= ' ' . $key . ' ' . \escapeshellarg($option ?? '');
} elseif (\in_array($key, ['image-dpi', 'image-quality'])) {
$command .= ' --' . $key . ' ' . (int) $option;
} else {
$command .= ' --' . $key . ' ' . \escapeshellarg($option);
$command .= ' --' . $key . ' ' . \escapeshellarg($option ?? '');
Comment on lines -549 to +553
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no need for this as we already check if an option is neither null or false at the beginning.

}
}
}
Expand Down