filterAttributes example

/** * @covers ::filterAttributes * * @dataProvider providerFilterAttributes * * @param string $html * Input HTML. * @param string $expected * The expected output string. */
  public function testfilterAttributes($html$expected) {
    $this->assertSame($expected$this->filter->filterAttributes($html));
  }

  /** * Provides data for testfilterAttributes. * * @return array * An array of test data. */
  public function providerFilterAttributes() {
    return [
      ['<a href="/blog" title="Blog">Blog</a>', '<a href="/blog">Blog</a>'],
      [

  public function process($text$langcode) {
    $restrictions = $this->getHtmlRestrictions();
    // Split the work into two parts. For filtering HTML tags out of the content     // we rely on the well-tested Xss::filter() code. Since there is no '*' tag     // that needs to be removed from the list.     unset($restrictions['allowed']['*']);
    $text = Xss::filter($textarray_keys($restrictions['allowed']));
    // After we've done tag filtering, we do attribute and attribute value     // filtering as the second part.     return new FilterProcessResult($this->filterAttributes($text));
  }

  /** * Provides filtering of tag attributes into accepted HTML. * * @param string $text * The HTML text string to be filtered. * * @return string * Filtered HTML with attributes filtered according to the settings. */
  
Home | Imprint | This part of the site doesn't use cookies.