Skip to content

Commit 5676487

Browse files
committed
Merge pull request php-debugbar#44 from barryvdh/pdo-escaping
Check parameters for binary data
2 parents 11271b8 + a8aabe8 commit 5676487

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

src/DebugBar/DataCollector/PDO/TracedStatement.php

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,14 +51,29 @@ public function __construct($sql, array $params = array(), $preparedId = null, $
5151
{
5252
$this->sql = $sql;
5353
$this->rowCount = $rowCount;
54-
$this->parameters = $params;
54+
$this->parameters = $this->checkParameters($params);
5555
$this->preparedId = $preparedId;
5656
$this->startTime = $startTime;
5757
$this->endTime = $endTime;
5858
$this->duration = $endTime - $startTime;
5959
$this->memoryUsage = $memoryUsage;
6060
$this->exception = $e;
6161
}
62+
63+
/**
64+
* Check parameters for illegal (non UTF-8) strings, like Binary data.
65+
*
66+
* @param $params
67+
* @return mixed
68+
*/
69+
public function checkParameters($params){
70+
foreach($params as &$param){
71+
if(!mb_check_encoding($param, 'UTF-8')){
72+
$param = '[BINARY DATA]';
73+
}
74+
}
75+
return $params;
76+
}
6277

6378
/**
6479
* Returns the SQL string used for the query

0 commit comments

Comments
 (0)