check_markup example


  public function render(ResultRow $values) {
    $value = $this->getValue($values);
    if (is_array($this->format)) {
      $format = $this->getValue($values, 'format');
    }
    else {
      $format = $this->format;
    }
    if ($value) {
      $value = str_replace('<!--break-->', '', $value);
      return check_markup($value$format);
    }
  }

  /** * {@inheritdoc} */
  public function elementType($none_supported = FALSE, $default_empty = FALSE, $inline = FALSE) {
    if ($inline) {
      return 'span';
    }

    
'settings' => [
            'allowed_html' => '<p>',
          ],
        ],
      ],
    ]);
    $crazy_format->save();

    $text = "<p>Llamas are <not> awesome!</p>";
    $expected_filtered_text = "&lt;p&gt;Llamas are awesome!&lt;/p&gt;";

    $this->assertEquals($expected_filtered_textcheck_markup($text, 'crazy'), 'Filters applied in correct order.');
  }

  /** * Tests the ability to apply only a subset of filters. */
  public function testCheckMarkupFilterSubset() {
    $text = "Text with <marquee>evil content and</marquee> a URL: https://www.drupal.org!";
    $expected_filtered_text = "Text with evil content and a URL: <a href=\"https://www.drupal.org\">https://www.drupal.org</a>!";
    $expected_filter_text_without_html_generators = "Text with evil content and a URL: https://www.drupal.org!";

    $actual_filtered_text = check_markup($text, 'filtered_html', '', []);
    


    // Execute the view.     $this->executeView($view);

    $view->display_handler->handlers['header']['area']->options['content']['format'] = $this->randomString();
    $build = $view->display_handler->handlers['header']['area']->render();
    $this->assertEquals('', $renderer->renderRoot($build), 'Nonexistent format should return empty markup.');

    $view->display_handler->handlers['header']['area']->options['content']['format'] = filter_default_format();
    $build = $view->display_handler->handlers['header']['area']->render();
    $this->assertEquals(check_markup($string)$renderer->renderRoot($build), 'Existent format should return something');

    // Empty results, and it shouldn't be displayed .     $this->assertEquals([]$view->display_handler->handlers['header']['area']->render(TRUE), 'No result should lead to no header');
    // Empty results, and it should be displayed.     $view->display_handler->handlers['header']['area']->options['empty'] = TRUE;
    $build = $view->display_handler->handlers['header']['area']->render(TRUE);
    $this->assertEquals(check_markup($string)$renderer->renderRoot($build), 'No result, but empty enabled lead to a full header');
  }

}
// Verify that the content is empty, because the text format does not exist.     $this->drupalGet('node/' . $node->id());
    $this->assertSession()->pageTextNotContains($body_raw);
  }

  /** * Tests that security filters are enforced even when marked to be skipped. */
  public function testSkipSecurityFilters() {
    $text = "Text with some disallowed tags: <script />, <p><object>unicorn</object></p>, <i><table></i>.";
    $expected_filtered_text = "Text with some disallowed tags: , <p>unicorn</p>, .";
    $this->assertSame($expected_filtered_text(string) check_markup($text, 'filtered_html', '', []), 'Expected filter result.');
    $this->assertSame($expected_filtered_text(string) check_markup($text, 'filtered_html', '', [FilterInterface::TYPE_HTML_RESTRICTOR]), 'Expected filter result, even when trying to disable filters of the FilterInterface::TYPE_HTML_RESTRICTOR type.');
  }

}

  public function testCheckMarkupNoFormat() {
    $this->installConfig(['filter']);

    // Create some text. Include some HTML and line breaks, so we get a good     // test of the filtering that is applied to it.     $text = "<strong>" . $this->randomMachineName(32) . "</strong>\n\n<div>" . $this->randomMachineName(32) . "</div>";

    // Make sure that when this text is run through check_markup() with no text     // format, it is filtered as though it is in the fallback format.     $this->assertEquals(check_markup($text)check_markup($textfilter_fallback_format()));
  }

}
Home | Imprint | This part of the site doesn't use cookies.