You are here

public function DefaultController::lightbox2_filter_xss in Lightbox2 8

Same name in this branch
  1. 8 src/DefaultController.php \Drupal\lightbox2\DefaultController::lightbox2_filter_xss()
  2. 8 src/Controller/DefaultController.php \Drupal\lightbox2\Controller\DefaultController::lightbox2_filter_xss()

File

src/DefaultController.php, line 9

Class

DefaultController
Default controller for the lightbox2 module.

Namespace

Drupal\lightbox2

Code

public function lightbox2_filter_xss() {
  $allowed_tags = trim(variable_get('lightbox2_filter_xss_allowed_tags', 'p, br, a, em, strong, cite, code, ul, ol, li, dl, dt, dd, '));
  $allowed_tags = empty($allowed_tags) ? [] : preg_split('/[,\\s]+/', $allowed_tags);
  if (!empty($_POST['allowed_tags']) && $_POST['allowed_tags'] != 'undefined') {
    $allowed_tags = explode(',', $_POST['allowed_tags']);
    $output = filter_xss($_POST['string'], $allowed_tags);
  }
  else {
    $output = filter_xss($_POST['string'], $allowed_tags);
  }
  drupal_json_output($output);
}