Commit 6e9908e6 authored by Paul Reeves's avatar Paul Reeves Committed by Damien McKenna
Browse files

Issue #3192117 by wells, reevo, Anybody, ScorpionGhost, joelpittet,...

Issue #3192117 by wells, reevo, Anybody, ScorpionGhost, joelpittet, Shenron_segamag, DamienMcKenna, Antonín Slejška, demon326, osopolar, Liliplanet, longwave, vipin.mittal18, William Aubert, markconroy: Metatags have encoded HTML entities instead of plain text content.
parent 427cd217
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -2,6 +2,7 @@

namespace Drupal\schema_metatag\Plugin\metatag\Tag;

use Drupal\Component\Render\PlainTextOutput;
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
use Drupal\metatag\Plugin\metatag\Tag\MetaNameBase;
use Drupal\schema_metatag\Plugin\schema_metatag\PropertyTypeManager;
@@ -270,6 +271,10 @@ protected function processItem(&$value, $key = 0) {
    // Parse out the image URL, if needed.
    $value = $this->parseImageUrlValue($value, $explode);

    // Convert value to plain text.
    $value = PlainTextOutput::renderFromHtml($value);

    // Trim resulting plain text value.
    $value = trim($value);

    // If tag must be secure, convert all http:// to https://.
+19 −0
Original line number Diff line number Diff line
@@ -7,6 +7,11 @@
/**
 * Provides a plugin for the 'Text' Schema.org property type.
 *
 * This type converts values to plain text. HTML content is removed from the
 * value during processing.
 *
 * @see \Drupal\schema_metatag\Plugin\metatag\Tag\SchemaNameBase::processItem()
 *
 * @SchemaPropertyType(
 *   id = "text",
 *   label = @Translation("Text"),
@@ -16,4 +21,18 @@
 */
class Text extends PropertyTypeBase {

  /**
   * {@inheritdoc}
   */
  public function testValue($type = '') {
    return '<p>A string <strong>with</strong> <em>some</em> <a href="https://www.drupal.org">HTML</a>!</p>';
  }

  /**
   * {@inheritdoc}
   */
  public function processedTestValue($items) {
    return 'A string with some HTML!';
  }

}