12345678910111213141516171819202122 |
- <?php
- namespace demo\Views;
- use Silex\Application;
- use Symfony\Component\HttpFoundation\Request;
- /**
- * Class JsonView is a JSON view handler.
- *
- * @package demo\Views
- */
- class JsonView {
- public function handle(array $controllerResult, Request $request) {
- // Does limited escaping using JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_AMP | JSON_HEX_QUOT.
- // Try /hello-json/<script>alert('Yo');<script> : Chrome with JSON Decode
- // extension throws JS error, which proves interpretation is triggered. This
- // is actually due to the extension.
- return $GLOBALS['app']->json($controllerResult);
- }
- }
|