Skip to content

Commit

Permalink
Merge branch 'master' into releases/1.8.x
Browse files Browse the repository at this point in the history
  • Loading branch information
stayallive committed Feb 7, 2018
2 parents 3241b13 + 23a717e commit 8c6dd0d
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 3 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@

- ...

## 1.8.3 (2018-02-07)

- Serialize breadcrumbs to prevent issues with binary data (#538)
- Fix notice array_key_exists() expects parameter 2 to be array, null given (#527)

## 1.8.2 (2017-12-21)

- Improve handling DSN with "null" like values (#522)
Expand Down
3 changes: 3 additions & 0 deletions lib/Raven/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -925,6 +925,9 @@ public function sanitize(&$data)
if (!empty($data['contexts'])) {
$data['contexts'] = $this->serializer->serialize($data['contexts'], 5);
}
if (!empty($data['breadcrumbs'])) {
$data['breadcrumbs'] = $this->serializer->serialize($data['breadcrumbs'], 5);
}
}

/**
Expand Down
8 changes: 5 additions & 3 deletions lib/Raven/Stacktrace.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ public static function get_stack_info($frames,
*/
$result = array();
for ($i = 0; $i < count($frames); $i++) {
$frame = isset($frames[$i]) ? $frames[$i] : null;
$nextframe = isset($frames[$i + 1]) ? $frames[$i + 1] : null;
$frame = isset($frames[$i]) ? $frames[$i] : array();
$nextframe = isset($frames[$i + 1]) ? $frames[$i + 1] : array();

if (!array_key_exists('file', $frame)) {
$context = array();
Expand All @@ -50,8 +50,10 @@ public static function get_stack_info($frames,
} catch (ReflectionException $e) {
// Forget it if we run into errors, it's not worth it.
}
} else {
} elseif (!empty($frame['function'])) {
$context['line'] = sprintf('%s(anonymous)', $frame['function']);
} else {
$context['line'] = sprintf('(anonymous)');
}

if (empty($context['filename'])) {
Expand Down
30 changes: 30 additions & 0 deletions test/Raven/Tests/ClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -1281,6 +1281,36 @@ public function testSanitizeContexts()
)), $data);
}

/**
* @covers Raven_Client::sanitize
*/
public function testSanitizeBreadcrumbs()
{
$client = new Dummy_Raven_Client();
$data = array('breadcrumbs' => array(array(
'message' => 'foo',
'utf8' => pack("NA3CC", 3, "aBc", 0x0D, 0x0A),
'data' => array(
'line' => 1216,
'bindings' => array(
array('foo', pack("NA3CC", 3, "aBc", 0x0D, 0x0A)),
)
),
)));
$client->sanitize($data);

$this->assertEquals(array('breadcrumbs' => array(array(
'message' => 'foo',
'utf8' => mb_convert_encoding(pack("NA3CC", 3, "aBc", 0x0D, 0x0A), 'UTF-8'),
'data' => array(
'line' => 1216,
'bindings' => array(
array('foo', mb_convert_encoding(pack("NA3CC", 3, "aBc", 0x0D, 0x0A), 'UTF-8')),
)
),
))), $data);
}

/**
* @covers Raven_Client::buildCurlCommand
*/
Expand Down
14 changes: 14 additions & 0 deletions test/Raven/Tests/StacktraceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,20 @@ public function testInAppWithAnonymous()
$this->assertEquals($frames[0]['in_app'], false);
}

public function testInAppWithEmptyFrame()
{
$stack = array(
array(
"function" => "{closure}",
),
null
);

$frames = Raven_Stacktrace::get_stack_info($stack, true, null, 0, null, dirname(__FILE__));

$this->assertEquals($frames[0]['in_app'], false);
}

public function testInAppWithExclusion()
{
$stack = array(
Expand Down

0 comments on commit 8c6dd0d

Please sign in to comment.