Skip to content

Commit

Permalink
[BUGFIX:BP:11] Use always string instead of null in all trim() calls
Browse files Browse the repository at this point in the history
Fixes: #195
  • Loading branch information
dkd-kaehm committed Sep 28, 2022
1 parent e4f062e commit ef2028b
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion Classes/Process.php
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ public function findPid(): ?int
exec($ps, $output);

foreach ($output as $line) {
[$pid, $command] = explode(' ', trim($line), 2);
[$pid, $command] = explode(' ', trim($line ?? ''), 2);
$command = $this->escapePsOutputCommand($command);
if ($command == $processCommand) {
return (int)$pid;
Expand Down
2 changes: 1 addition & 1 deletion Classes/Service/Tika/AbstractService.php
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ protected function getAdditionalCommandOptions(): string
// Combine matched command options with escaped argument value
$commandOptionsString = '';
foreach (array_combine($matches['property'], $matches['value']) as $property => $unescapedValue) {
$escapedValue = CommandUtility::escapeShellArgument(trim($unescapedValue, '"\''));
$escapedValue = CommandUtility::escapeShellArgument(trim($unescapedValue ?? '', '"\''));
$commandOptionsString .= sprintf(' -D%s=%s', $property, $escapedValue);
}

Expand Down
8 changes: 4 additions & 4 deletions Classes/Service/Tika/AppService.php
Original file line number Diff line number Diff line change
Expand Up @@ -235,10 +235,10 @@ public function buildSupportedMimeTypes(): array
}

/**
* Takes shell output from exec() and turns it into an array of key => value
* Takes the shell output from exec() and turns it into an array of key => value
* pairs.
*
* @param array $shellOutput An array containing shell output from exec() with one line per entry
* @param array $shellOutput An array containing the shell output from exec() with one line per entry
* @return array Key => value pairs
*/
protected function shellOutputToArray(array $shellOutput): array
Expand All @@ -247,7 +247,7 @@ protected function shellOutputToArray(array $shellOutput): array

foreach ($shellOutput as $line) {
[$key, $value] = explode(':', $line, 2);
$value = trim($value);
$value = trim($value ?? '');

if (in_array($key, [
'dc',
Expand All @@ -263,7 +263,7 @@ protected function shellOutputToArray(array $shellOutput): array
[$key, $value] = explode(':', $value, 2);

$key = $keyPrefix . ':' . $key;
$value = trim($value);
$value = trim($value ?? '');
}

if (array_key_exists($key, $metaData)) {
Expand Down

0 comments on commit ef2028b

Please sign in to comment.