Skip to content

Commit

Permalink
Merge pull request #98 from MindscapeHQ/raygun4php-escapeshellarg-bug…
Browse files Browse the repository at this point in the history
…-fix

Escapeshellarg input contains null bytes
  • Loading branch information
BenjaminHarding committed Jan 8, 2018
2 parents febdb06 + 16e36a5 commit 6d28cbb
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 3 deletions.
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
language: php

php: [5.3, 5.4, 5.5]
php: [5.4, 5.5, 7.0]

before_script:
- composer self-update
- composer install --dev --prefer-source --no-interaction --no-progress

script: 'vendor/bin/phpunit tests'
script: 'vendor/bin/phpunit tests'
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,7 @@ See the [Error Control Operators section on PHP.net](http://php.net/manual/en/la

## Changelog

- 1.8.1: Fix issue with error being raised with null bytes send with escapeshellarg method
- 1.8.0: Bugfix with multiple cookies being set. Cookie options can be set via the setCookieOptions method
- 1.7.1: Fixed illegal string offset
- 1.7.0: Added custom error grouping
Expand Down
9 changes: 9 additions & 0 deletions src/Raygun4php/RaygunClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,11 @@ public function Send($message)

$message = $this->filterParamsFromMessage($message);
$message = $this->toJsonRemoveUnicodeSequences($message);
$message = $this->removeNullBytes($message);

if(strlen($message) <= 0) {
return null;
}

return $this->post($message, realpath(__DIR__ . '/cacert.crt'));
}
Expand Down Expand Up @@ -414,6 +419,10 @@ function toJsonRemoveUnicodeSequences($struct) {
return preg_replace_callback("/\\\\u([a-f0-9]{4})/", function($matches){ return iconv('UCS-4LE','UTF-8',pack('V', hexdec("U$matches[1]"))); }, json_encode($struct));
}

function removeNullBytes($string) {
return str_replace("\0", '', $string);
}

/**
* Optionally applies a value transformation to every matching key, as defined by {@link FilterParams}.
* Replaces the value by default, but also supports custom transformations through
Expand Down
2 changes: 1 addition & 1 deletion src/Raygun4php/RaygunClientMessage.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class RaygunClientMessage
public function __construct()
{
$this->Name = "Raygun4php";
$this->Version = "1.8.0";
$this->Version = "1.8.1";
$this->ClientUrl = "https://github.com/MindscapeHQ/raygun4php";
}
}
Expand Down

0 comments on commit 6d28cbb

Please sign in to comment.