コード例 #1
0
 /**
  * Tests the spam deterrent.
  */
 function testNoFollowFilter()
 {
     // Get FilterHtml object.
     $filter = $this->filters['filter_html'];
     $filter->setConfiguration(array('settings' => array('allowed_html' => '<a>', 'filter_html_help' => 1, 'filter_html_nofollow' => 1)));
     // Test if the rel="nofollow" attribute is added, even if we try to prevent
     // it.
     $f = _filter_html('<a href="http://www.example.com/">text</a>', $filter);
     $this->assertNormalized($f, 'rel="nofollow"', 'Spam deterrent -- no evasion.');
     $f = _filter_html('<A href="http://www.example.com/">text</a>', $filter);
     $this->assertNormalized($f, 'rel="nofollow"', 'Spam deterrent evasion -- capital A.');
     $f = _filter_html("<a/href=\"http://www.example.com/\">text</a>", $filter);
     $this->assertNormalized($f, 'rel="nofollow"', 'Spam deterrent evasion -- non whitespace character after tag name.');
     $f = _filter_html("<a href=\"http://www.example.com/\">text</a>", $filter);
     $this->assertNormalized($f, 'rel="nofollow"', 'Spam deterrent evasion -- some nulls.');
     $f = _filter_html('<a href="http://www.example.com/" rel="follow">text</a>', $filter);
     $this->assertNoNormalized($f, 'rel="follow"', 'Spam deterrent evasion -- with rel set - rel="follow" removed.');
     $this->assertNormalized($f, 'rel="nofollow"', 'Spam deterrent evasion -- with rel set - rel="nofollow" added.');
 }
コード例 #2
0
ファイル: FilterHtml.php プロジェクト: alnutile/drunatra
 /**
  * {@inheritdoc}
  */
 public function process($text, $langcode)
 {
     return new FilterProcessResult(_filter_html($text, $this));
 }