Skip to content

Commit 1f6f748

Browse files
committed
Escape query bindings
Fixes #198
1 parent 1171ca4 commit 1f6f748

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

changelog.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
# Changelog for Laravel Debugbar
22

3-
## 1.7.7 (2014-09-..)
3+
## 1.7.7 (2014-09-15)
44

55
- Make it compatible with Laravel 5.0-dev
66
- Allow anonymous function as `enabled` setting (for IP checks etc)
7+
- Escape query bindings, to prevent executing of scripts/html
78

89
## 1.7.6 (2014-09-12)
910

src/DataCollector/QueryCollector.php

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ public function addQuery($query, $bindings, $time, $connection)
7676

7777
$this->queries[] = array(
7878
'query' => $query,
79-
'bindings' => $bindings,
79+
'bindings' => $this->escapeBindings($bindings),
8080
'time' => $time,
8181
'source' => $source,
8282
);
@@ -102,6 +102,20 @@ protected function checkBindings($bindings)
102102
return $bindings;
103103
}
104104

105+
/**
106+
* Make the bindings safe for outputting.
107+
*
108+
* @param array $bindings
109+
* @return array
110+
*/
111+
protected function escapeBindings($bindings)
112+
{
113+
foreach ($bindings as &$binding) {
114+
$binding = htmlentities($binding, ENT_QUOTES, 'UTF-8', false);
115+
}
116+
return $bindings;
117+
}
118+
105119
/**
106120
* Use a backtrace to search for the origin of the query.
107121
*/

0 commit comments

Comments
 (0)