Skip to content

Commit 5987f1c

Browse files
committed
Merge branch '5.4' into 6.4
* 5.4: Fix XSS in example event dispatcher
2 parents e8345e1 + 4f64f71 commit 5987f1c

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

event_dispatcher.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@ The most common way to listen to an event is to register an **event listener**::
4141
// Customize your response object to display the exception details
4242
$response = new Response();
4343
$response->setContent($message);
44+
// the exception message can contain unfiltered user input;
45+
// set the content-type to text to avoid XSS issues
46+
$response->headers->set('Content-Type', 'text/plain; charset=utf-8');
4447

4548
// HttpExceptionInterface is a special type of exception that
4649
// holds status code and header details

0 commit comments

Comments
 (0)