Skip to content

Commit

Permalink
Merge pull request #554 from martinstuecklschwaiger/master
Browse files Browse the repository at this point in the history
Allow $data['request'] to be 5 levels deep
  • Loading branch information
stayallive authored Apr 20, 2018
2 parents f9678f0 + c40ee31 commit 625d5e5
Show file tree
Hide file tree
Showing 2 changed files with 76 additions and 9 deletions.
2 changes: 1 addition & 1 deletion lib/Raven/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -935,7 +935,7 @@ public function sanitize(&$data)
{
// attempt to sanitize any user provided data
if (!empty($data['request'])) {
$data['request'] = $this->serializer->serialize($data['request']);
$data['request'] = $this->serializer->serialize($data['request'], 5);
}
if (!empty($data['user'])) {
$data['user'] = $this->serializer->serialize($data['user'], 3);
Expand Down
83 changes: 75 additions & 8 deletions test/Raven/Tests/ClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -1477,21 +1477,88 @@ public function testSanitizeUser()
public function testSanitizeRequest()
{
$client = new Dummy_Raven_Client();

// Typical content of $_POST in PHP
$post = array(
'_method' => 'POST',
'data' => array(
'MyModel' => array(
'flatField' => 'my value',
'nestedField' => array(
'key' => 'my other value',
),
),
),
);

$data = array('request' => array(
'context' => array(
'line' => 1216,
'stack' => array(
1, array(2), 3
'method' => 'POST',
'url' => 'https://example.com/something',
'query_string' => '',
'data' => $post,
));

$client->sanitize($data);

$this->assertEquals(array('request' => array(
'method' => 'POST',
'url' => 'https://example.com/something',
'query_string' => '',
'data' => array(
'_method' => 'POST',
'data' => array(
'MyModel' => array(
'flatField' => 'my value',
'nestedField' => array(
'key' => 'my other value',
),
),
),
),
)), $data);
}

/**
* @covers Raven_Client::sanitize
*/
public function testSanitizeDeepRequest()
{
$client = new Dummy_Raven_Client();

$post = array(
'_method' => 'POST',
'data' => array(
'Level 1' => array(
'Level 2' => array(
'Level 3' => array(
'Level 4' => 'something',
),
),
),
),
);

$data = array('request' => array(
'method' => 'POST',
'url' => 'https://example.com/something',
'query_string' => '',
'data' => $post,
));

$client->sanitize($data);

$this->assertEquals(array('request' => array(
'context' => array(
'line' => 1216,
'stack' => array(
1, 'Array of length 1', 3
'method' => 'POST',
'url' => 'https://example.com/something',
'query_string' => '',
'data' => array(
'_method' => 'POST',
'data' => array(
'Level 1' => array(
'Level 2' => array(
'Level 3' => 'Array of length 1',
),
),
),
),
)), $data);
Expand Down

0 comments on commit 625d5e5

Please sign in to comment.