Skip to content

Commit 10fee8c

Browse files
committed
[HttpKernel] added escaping to the profiler SQLite storage
1 parent 50809d2 commit 10fee8c

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

src/Symfony/Bundle/WebProfilerBundle/Controller/ProfilerController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ public function searchAction()
233233
$tokens = $profiler->find($ip, $url, $limit);
234234

235235
$response = $this->container->get('response');
236-
$response->setRedirect($this->container->get('router')->generate('_profiler_search_results', array('token' => $tokens[0]['token'])));
236+
$response->setRedirect($this->container->get('router')->generate('_profiler_search_results', array('token' => $tokens ? $tokens[0]['token'] : '')));
237237

238238
return $response;
239239
}

src/Symfony/Component/HttpKernel/Profiler/SQLiteProfilerStorage.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,19 +40,20 @@ public function __construct($store, $lifetime = 86400)
4040
*/
4141
public function find($ip, $url, $limit)
4242
{
43+
$db = $this->initDb();
44+
4345
$criteria = array();
4446

4547
if ($ip = preg_replace('/[^\d\.]/', '', $ip)) {
46-
$criteria[] = ' ip LIKE "%'.$ip.'%"';
48+
$criteria[] = " ip LIKE '%".$ip."%'";
4749
}
4850

4951
if ($url) {
50-
$criteria[] = ' url LIKE "%'.$url.'%"';
52+
$criteria[] = " url LIKE '%".$db->escapeString($url)."%'";
5153
}
5254

5355
$criteria = $criteria ? 'WHERE '.implode(' AND ', $criteria) : '';
5456

55-
$db = $this->initDb();
5657
$tokens = $this->fetch($db, 'SELECT token, ip, url, time FROM data '.$criteria.' ORDER BY time DESC LIMIT '.((integer) $limit));
5758
$this->close($db);
5859

0 commit comments

Comments
 (0)