From b1d1d215c732ca5732257d6fb258eca9261b9e9e Mon Sep 17 00:00:00 2001 From: Dawid 'DeyV' Polak Date: Sun, 7 Jan 2018 16:23:50 +0100 Subject: [PATCH 1/3] default value for array should be array (#527) * default value for array should be array - fix notice array_key_exists() expects parameter 2 to be array, null given * Test for Raven_Stacktrace - testInAppWithEmptyFrame --- lib/Raven/Stacktrace.php | 8 +++++--- test/Raven/Tests/StacktraceTest.php | 14 ++++++++++++++ 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/lib/Raven/Stacktrace.php b/lib/Raven/Stacktrace.php index c3353d799..945e68d57 100644 --- a/lib/Raven/Stacktrace.php +++ b/lib/Raven/Stacktrace.php @@ -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(); @@ -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'])) { diff --git a/test/Raven/Tests/StacktraceTest.php b/test/Raven/Tests/StacktraceTest.php index c0f3c4cdc..641cc1128 100644 --- a/test/Raven/Tests/StacktraceTest.php +++ b/test/Raven/Tests/StacktraceTest.php @@ -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( From 0904031c3420256a0f28b2994f68df7880a4bbf5 Mon Sep 17 00:00:00 2001 From: Ryan White Date: Mon, 5 Feb 2018 03:21:23 -0500 Subject: [PATCH 2/3] Adding breadcrumbs to sanitize / serialize. (#538) --- lib/Raven/Client.php | 3 +++ test/Raven/Tests/ClientTest.php | 30 ++++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+) diff --git a/lib/Raven/Client.php b/lib/Raven/Client.php index 346cfdc6c..85492a57e 100644 --- a/lib/Raven/Client.php +++ b/lib/Raven/Client.php @@ -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); + } } /** diff --git a/test/Raven/Tests/ClientTest.php b/test/Raven/Tests/ClientTest.php index 112dee5c3..82eb49d28 100644 --- a/test/Raven/Tests/ClientTest.php +++ b/test/Raven/Tests/ClientTest.php @@ -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 */ From 7a297d018caa050c7b7904ca2e23529b8b760b37 Mon Sep 17 00:00:00 2001 From: Alex Bouma Date: Wed, 7 Feb 2018 09:37:24 +0100 Subject: [PATCH 3/3] Update changelog for version 1.8.3 --- CHANGELOG.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 80756057b..11c6ca486 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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)