1
0
mirror of https://github.com/ezyang/htmlpurifier.git synced 2025-07-31 03:10:09 +02:00

Implement lang and xml:lang. Fixed a bunch of bugs too.

git-svn-id: http://htmlpurifier.org/svnroot/htmlpurifier/trunk@162 48356398-32a2-884e-a903-53898d9a118a
This commit is contained in:
Edward Z. Yang
2006-08-05 01:50:13 +00:00
parent 1945ddca5c
commit 8a23710405
11 changed files with 312 additions and 7 deletions

View File

@@ -0,0 +1,31 @@
<?php
require_once 'HTMLPurifier/AttrTransform.php';
class HTMLPurifier_AttrTransform_Lang extends HTMLPurifier_AttrTransform
{
function transform($token) {
$lang = isset($token->attributes['lang']) ?
$token->attributes['lang'] : false;
$xml_lang = isset($token->attributes['xml:lang']) ?
$token->attributes['xml:lang'] : false;
if ($lang === false && $xml_lang == false) return $token;
$new_token = $token->copy();
if ($lang !== false && $xml_lang === false) {
$new_token->attributes['xml:lang'] = $lang;
} elseif ($xml_lang !== false) {
$new_token->attributes['lang'] = $xml_lang;
}
return $new_token;
}
}
?>