Skip to content

Commit

Permalink
Escape query bindings
Browse files Browse the repository at this point in the history
Fixes #198
  • Loading branch information
barryvdh committed Sep 15, 2014
1 parent 1171ca4 commit 1f6f748
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
3 changes: 2 additions & 1 deletion changelog.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
# Changelog for Laravel Debugbar

## 1.7.7 (2014-09-..)
## 1.7.7 (2014-09-15)

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

## 1.7.6 (2014-09-12)

Expand Down
16 changes: 15 additions & 1 deletion src/DataCollector/QueryCollector.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public function addQuery($query, $bindings, $time, $connection)

$this->queries[] = array(
'query' => $query,
'bindings' => $bindings,
'bindings' => $this->escapeBindings($bindings),
'time' => $time,
'source' => $source,
);
Expand All @@ -102,6 +102,20 @@ protected function checkBindings($bindings)
return $bindings;
}

/**
* Make the bindings safe for outputting.
*
* @param array $bindings
* @return array
*/
protected function escapeBindings($bindings)
{
foreach ($bindings as &$binding) {
$binding = htmlentities($binding, ENT_QUOTES, 'UTF-8', false);
}
return $bindings;
}

/**
* Use a backtrace to search for the origin of the query.
*/
Expand Down

0 comments on commit 1f6f748

Please sign in to comment.