mirror of
https://github.com/ezyang/htmlpurifier.git
synced 2025-08-06 14:16:32 +02:00
Implement simple attribute transformations and roll them out.
git-svn-id: http://htmlpurifier.org/svnroot/htmlpurifier/trunk@152 48356398-32a2-884e-a903-53898d9a118a
This commit is contained in:
@@ -6,9 +6,9 @@ require_once 'HTMLPurifier/IDAccumulator.php';
|
||||
class HTMLPurifier_AttrDef_ID extends HTMLPurifier_AttrDef
|
||||
{
|
||||
|
||||
function validate($id, &$accumulator) {
|
||||
function validate($old_id, &$accumulator) {
|
||||
|
||||
$id = @ (string) $id; // sanity check
|
||||
$id = trim($old_id); // trim it first
|
||||
|
||||
if ($id === '') return false;
|
||||
if (isset($accumulator->ids[$id])) return false;
|
||||
@@ -19,7 +19,7 @@ class HTMLPurifier_AttrDef_ID extends HTMLPurifier_AttrDef
|
||||
$result = true;
|
||||
} else {
|
||||
if (!ctype_alpha(@$id[0])) return false;
|
||||
$trim = trim(
|
||||
$trim = trim( // primitive style of regexps, I suppose
|
||||
$id,
|
||||
'A..Za..z0..9:-._'
|
||||
);
|
||||
@@ -28,7 +28,10 @@ class HTMLPurifier_AttrDef_ID extends HTMLPurifier_AttrDef
|
||||
|
||||
if ($result) $accumulator->add($id);
|
||||
|
||||
return $result;
|
||||
// if no change was made to the ID, return the result
|
||||
// else, return the new id if stripping whitespace made it
|
||||
// valid, or return false.
|
||||
return ($id == $old_id) ? $result : ($result ? $id : false);
|
||||
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user