public function ViewSubscriber::onIframeUpload

File

drupal/core/lib/Drupal/Core/EventSubscriber/ViewSubscriber.php, line 113
Definition of Drupal\Core\EventSubscriber\ViewSubscriber.

Class

ViewSubscriber
Main subscriber for VIEW HTTP responses.

Namespace

Drupal\Core\EventSubscriber

Code

public function onIframeUpload(GetResponseForControllerResultEvent $event) {
  $page_callback_result = $event
    ->getControllerResult();

  // Construct the response content from the page callback result.
  $commands = ajax_prepare_response($page_callback_result);
  $json = ajax_render($commands);

  // Browser IFRAMEs expect HTML. Browser extensions, such as Linkification
  // and Skype's Browser Highlighter, convert URLs, phone numbers, etc. into
  // links. This corrupts the JSON response. Protect the integrity of the
  // JSON data by making it the value of a textarea.
  // @see http://malsup.com/jquery/form/#file-upload
  // @see http://drupal.org/node/1009382
  $html = '<textarea>' . $json . '</textarea>';
  return new Response($html);
}