public function EditorController::filterXss in Zircon Profile 8.0
Same name and namespace in other branches
- 8 core/modules/editor/src/EditorController.php \Drupal\editor\EditorController::filterXss()
Apply the necessary XSS filtering for using a certain text format's editor.
Parameters
\Symfony\Component\HttpFoundation\Request $request: The current request object.
\Drupal\filter\FilterFormatInterface $filter_format: The text format whose text editor (if any) will be used.
Return value
\Symfony\Component\HttpFoundation\JsonResponse A JSON response containing the XSS-filtered value.
Throws
\Symfony\Component\HttpKernel\Exception\NotFoundHttpException Thrown if no value to filter is specified.
See also
1 string reference to 'EditorController::filterXss'
- editor.routing.yml in core/
modules/ editor/ editor.routing.yml - core/modules/editor/editor.routing.yml
File
- core/
modules/ editor/ src/ EditorController.php, line 68 - Contains \Drupal\editor\EditorController.
Class
- EditorController
- Returns responses for Editor module routes.
Namespace
Drupal\editorCode
public function filterXss(Request $request, FilterFormatInterface $filter_format) {
$value = $request->request
->get('value');
if (!isset($value)) {
throw new NotFoundHttpException();
}
// The original_format parameter will only exist when switching text format.
$original_format_id = $request->request
->get('original_format_id');
$original_format = NULL;
if (isset($original_format_id)) {
$original_format = $this
->entityManager()
->getStorage('filter_format')
->load($original_format_id);
}
return new JsonResponse(editor_filter_xss($value, $filter_format, $original_format));
}