mirror of
https://github.com/ezyang/htmlpurifier.git
synced 2024-12-22 16:31:53 +00:00
Fix in AttrTransform_Nofollow
Signed-off-by: Edward Z. Yang <ezyang@mit.edu>
This commit is contained in:
parent
cb7162a995
commit
6705140082
1
NEWS
1
NEWS
@ -15,6 +15,7 @@ NEWS ( CHANGELOG and HISTORY ) HTMLPurifier
|
|||||||
transforms in later modules. No internal code was using this
|
transforms in later modules. No internal code was using this
|
||||||
but this may break some clients.
|
but this may break some clients.
|
||||||
- Use prepend for SPL autoloading on PHP 5.3 and later.
|
- Use prepend for SPL autoloading on PHP 5.3 and later.
|
||||||
|
- Fix bug with nofollow transform when pre-existing rel exists.
|
||||||
|
|
||||||
4.4.0, released 2012-01-18
|
4.4.0, released 2012-01-18
|
||||||
# Removed PEARSax3 handler.
|
# Removed PEARSax3 handler.
|
||||||
|
1
TODO
1
TODO
@ -13,6 +13,7 @@ afraid to cast your vote for the next feature to be implemented!
|
|||||||
|
|
||||||
Things to do as soon as possible:
|
Things to do as soon as possible:
|
||||||
|
|
||||||
|
- http://htmlpurifier.org/phorum/read.php?3,5560,6307#msg-6307
|
||||||
- Think about allowing explicit order of operations hooks for transforms
|
- Think about allowing explicit order of operations hooks for transforms
|
||||||
- Fix "<.<" bug (trailing < is removed if not EOD)
|
- Fix "<.<" bug (trailing < is removed if not EOD)
|
||||||
- Build in better internal state dumps and debugging tools for remote
|
- Build in better internal state dumps and debugging tools for remote
|
||||||
|
@ -26,7 +26,7 @@ class HTMLPurifier_AttrTransform_Nofollow extends HTMLPurifier_AttrTransform
|
|||||||
|
|
||||||
if ($scheme->browsable && !$url->isLocal($config, $context)) {
|
if ($scheme->browsable && !$url->isLocal($config, $context)) {
|
||||||
if (isset($attr['rel'])) {
|
if (isset($attr['rel'])) {
|
||||||
$rels = explode(' ', $attr);
|
$rels = explode(' ', $attr['rel']);
|
||||||
if (!in_array('nofollow', $rels)) {
|
if (!in_array('nofollow', $rels)) {
|
||||||
$rels[] = 'nofollow';
|
$rels[] = 'nofollow';
|
||||||
}
|
}
|
||||||
|
@ -6,18 +6,19 @@ class HTMLPurifier_HTMLModule_NofollowTest extends HTMLPurifier_HTMLModuleHarnes
|
|||||||
function setUp() {
|
function setUp() {
|
||||||
parent::setUp();
|
parent::setUp();
|
||||||
$this->config->set('HTML.Nofollow', true);
|
$this->config->set('HTML.Nofollow', true);
|
||||||
|
$this->config->set('Attr.AllowedRel', array("nofollow", "blah"));
|
||||||
}
|
}
|
||||||
|
|
||||||
function testNofollow() {
|
function testNofollow() {
|
||||||
$this->assertResult(
|
$this->assertResult(
|
||||||
'<a href="http://google.com">a</a><a href="/local">b</a><a href="mailto:foo@example.com">c</a>',
|
'<a href="http://google.com">x</a><a href="http://google.com" rel="blah">a</a><a href="/local">b</a><a href="mailto:foo@example.com">c</a>',
|
||||||
'<a href="http://google.com" rel="nofollow">a</a><a href="/local">b</a><a href="mailto:foo@example.com">c</a>'
|
'<a href="http://google.com" rel="nofollow">x</a><a href="http://google.com" rel="blah nofollow">a</a><a href="/local">b</a><a href="mailto:foo@example.com">c</a>'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function testNofollowDupe() {
|
function testNofollowDupe() {
|
||||||
$this->assertResult(
|
$this->assertResult(
|
||||||
'<a href="http://google.com" rel="nofollow">a</a><a href="/local">b</a><a href="mailto:foo@example.com">c</a>'
|
'<a href="http://google.com" rel="nofollow">x</a><a href="http://google.com" rel="blah nofollow">a</a><a href="/local">b</a><a href="mailto:foo@example.com">c</a>'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user