Commit b1c4dd2f authored by Matthias Muller's avatar Matthias Muller Committed by Christian Adamski
Browse files

Issue #3026041 by matthiasm11: Token escaping

parent 1117ab28
Loading
Loading
Loading
Loading
+7 −0
Changes for src/Plugin/Field/FieldFormatter/GeolocationGoogleMapFormatter.php: 7 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -2,6 +2,7 @@

namespace Drupal\geolocation\Plugin\Field\FieldFormatter;

use Drupal\Component\Render\PlainTextOutput;
use Drupal\Core\Field\FieldItemListInterface;
use Drupal\Core\Field\FormatterBase;
use Drupal\Core\Form\FormStateInterface;
@@ -207,14 +208,20 @@ class GeolocationGoogleMapFormatter extends FormatterBase {
        'callback' => [$this, 'geolocationItemTokens'],
        'clear' => TRUE,
      ]);

      $title = PlainTextOutput::renderFromHtml($title);

      if (empty($title)) {
        $title = $item->lat . ', ' . $item->lng;
      }

      $content = \Drupal::token()->replace($settings['info_text'], $token_context, [
        'callback' => [$this, 'geolocationItemTokens'],
        'clear' => TRUE,
      ]);

      $content = PlainTextOutput::renderFromHtml($content);

      $location = [
        '#theme' => 'geolocation_common_map_location',
        '#content' => $content,
+2 −0
Changes for src/Plugin/views/style/CommonMap.php: 2 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -2,6 +2,7 @@

namespace Drupal\geolocation\Plugin\views\style;

use Drupal\Component\Render\PlainTextOutput;
use Drupal\views\Plugin\views\style\StylePluginBase;
use Drupal\Core\Form\FormStateInterface;
use Drupal\geolocation\Plugin\views\field\GeolocationField;
@@ -151,6 +152,7 @@ class CommonMap extends StylePluginBase {
     */
    if (!empty($this->options['context_popup_content'])) {
      $context_popup_content = \Drupal::token()->replace($this->options['context_popup_content']);
      $context_popup_content = PlainTextOutput::renderFromHtml($context_popup_content);
      $build['#attached']['drupalSettings']['geolocation']['commonMap'][$map_id]['contextPopupContent'] = [];
      $build['#attached']['drupalSettings']['geolocation']['commonMap'][$map_id]['contextPopupContent']['enable'] = TRUE;
      $build['#attached']['drupalSettings']['geolocation']['commonMap'][$map_id]['contextPopupContent']['content'] = $context_popup_content;