Skip to content

Commit 6444124

Browse files
committed
added escaping to the examples in the doc
1 parent 89f1087 commit 6444124

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ require_once __DIR__.'/silex.phar';
1111

1212
$app = new Silex\Application();
1313

14-
$app->get('/hello/{name}', function ($name) {
15-
return "Hello $name";
14+
$app->get('/hello/{name}', function ($name) use ($app) {
15+
return 'Hello '.$app->escape($name);
1616
});
1717

1818
$app->run();

doc/intro.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ step.
2626

2727
$app = new Silex\Application();
2828

29-
$app->get('/hello/{name}', function ($name) {
30-
return "Hello $name";
29+
$app->get('/hello/{name}', function ($name) use ($app) {
30+
return 'Hello '.$app->escape($name);
3131
});
3232

3333
$app->run();

src/Silex/Application.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -257,9 +257,9 @@ public function redirect($url, $status = 302)
257257
* @param string $text The input text to be escaped
258258
* @return string Escaped text
259259
*/
260-
public function escape($text)
260+
public function escape($text, $flags = ENT_COMPAT, $charset = 'UTF-8', $doubleEncode = true)
261261
{
262-
return htmlspecialchars($text, ENT_COMPAT, 'UTF-8');
262+
return htmlspecialchars($text, $flags, $charset, $doubleEncode);
263263
}
264264

265265
/**

0 commit comments

Comments
 (0)