Commit 6444124a authored by Fabien Potencier's avatar Fabien Potencier

added escaping to the examples in the doc

parent 89f1087a
...@@ -11,8 +11,8 @@ require_once __DIR__.'/silex.phar'; ...@@ -11,8 +11,8 @@ require_once __DIR__.'/silex.phar';
$app = new Silex\Application(); $app = new Silex\Application();
$app->get('/hello/{name}', function ($name) { $app->get('/hello/{name}', function ($name) use ($app) {
return "Hello $name"; return 'Hello '.$app->escape($name);
}); });
$app->run(); $app->run();
......
...@@ -26,8 +26,8 @@ step. ...@@ -26,8 +26,8 @@ step.
$app = new Silex\Application(); $app = new Silex\Application();
$app->get('/hello/{name}', function ($name) { $app->get('/hello/{name}', function ($name) use ($app) {
return "Hello $name"; return 'Hello '.$app->escape($name);
}); });
$app->run(); $app->run();
......
...@@ -257,9 +257,9 @@ class Application extends \Pimple implements HttpKernelInterface, EventSubscribe ...@@ -257,9 +257,9 @@ class Application extends \Pimple implements HttpKernelInterface, EventSubscribe
* @param string $text The input text to be escaped * @param string $text The input text to be escaped
* @return string Escaped text * @return string Escaped text
*/ */
public function escape($text) public function escape($text, $flags = ENT_COMPAT, $charset = 'UTF-8', $doubleEncode = true)
{ {
return htmlspecialchars($text, ENT_COMPAT, 'UTF-8'); return htmlspecialchars($text, $flags, $charset, $doubleEncode);
} }
/** /**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment