mirror of
https://github.com/ezyang/htmlpurifier.git
synced 2024-11-09 15:28:40 +00:00
Do not duplicate nofollow attribute in transform.
Signed-off-by: Edward Z. Yang <ezyang@mit.edu>
This commit is contained in:
parent
35b1fbce01
commit
820d6e9097
2
NEWS
2
NEWS
@ -15,6 +15,8 @@ NEWS ( CHANGELOG and HISTORY ) HTMLPurifier
|
|||||||
- Color keywords are now case insensitive. Thanks Yzmir Ramirez
|
- Color keywords are now case insensitive. Thanks Yzmir Ramirez
|
||||||
<yramirez-htmlpurifier@adicio.com> for reporting.
|
<yramirez-htmlpurifier@adicio.com> for reporting.
|
||||||
- Explicitly initialize anonModule variable to null.
|
- Explicitly initialize anonModule variable to null.
|
||||||
|
- Do not duplicate nofollow if already present. Thanks 178
|
||||||
|
for reporting.
|
||||||
|
|
||||||
4.3.0, released 2011-03-27
|
4.3.0, released 2011-03-27
|
||||||
# Fixed broken caching of customized raw definitions, but requires an
|
# Fixed broken caching of customized raw definitions, but requires an
|
||||||
|
@ -26,7 +26,11 @@ class HTMLPurifier_AttrTransform_Nofollow extends HTMLPurifier_AttrTransform
|
|||||||
|
|
||||||
if (!is_null($url->host) && $scheme !== false && $scheme->browsable) {
|
if (!is_null($url->host) && $scheme !== false && $scheme->browsable) {
|
||||||
if (isset($attr['rel'])) {
|
if (isset($attr['rel'])) {
|
||||||
$attr['rel'] .= ' nofollow';
|
$rels = explode(' ', $attr);
|
||||||
|
if (!in_array('nofollow', $rels)) {
|
||||||
|
$rels[] = 'nofollow';
|
||||||
|
}
|
||||||
|
$attr['rel'] = implode(' ', $rels);
|
||||||
} else {
|
} else {
|
||||||
$attr['rel'] = 'nofollow';
|
$attr['rel'] = 'nofollow';
|
||||||
}
|
}
|
||||||
|
@ -15,6 +15,12 @@ class HTMLPurifier_HTMLModule_NofollowTest extends HTMLPurifier_HTMLModuleHarnes
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function testNofollowDupe() {
|
||||||
|
$this->assertResult(
|
||||||
|
'<a href="http://google.com" rel="nofollow">a</a><a href="/local">b</a><a href="mailto:foo@example.com">c</a>'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// vim: et sw=4 sts=4
|
// vim: et sw=4 sts=4
|
||||||
|
Loading…
Reference in New Issue
Block a user