mirror of
https://github.com/ezyang/htmlpurifier.git
synced 2025-07-31 19:30:21 +02:00
Add NumberSpan definition (non-DTD, but applies to enough to be useful). All widely used non-deprecated attributes have been implemented (except for rel/rev, but that's tricky). Add note about quirky COL handling and possible implementation of a workaround.
git-svn-id: http://htmlpurifier.org/svnroot/htmlpurifier/trunk@174 48356398-32a2-884e-a903-53898d9a118a
This commit is contained in:
23
library/HTMLPurifier/AttrDef/NumberSpan.php
Normal file
23
library/HTMLPurifier/AttrDef/NumberSpan.php
Normal file
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
require_once 'HTMLPurifier/AttrDef.php';
|
||||
|
||||
// for col and row spans, essentially, a positive integer
|
||||
class HTMLPurifier_AttrDef_NumberSpan extends HTMLPurifier_AttrDef
|
||||
{
|
||||
|
||||
function validate($string) {
|
||||
|
||||
$string = trim($string);
|
||||
if ($string === '') return false;
|
||||
if ($string === '1') return false; // this is the default value
|
||||
if (!is_numeric($string)) return false;
|
||||
$int = (int) $string;
|
||||
if ($int <= 0) return false;
|
||||
return (string) $int;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
@@ -9,6 +9,7 @@ require_once 'HTMLPurifier/AttrDef.php';
|
||||
require_once 'HTMLPurifier/AttrDef/Pixels.php';
|
||||
require_once 'HTMLPurifier/AttrDef/Length.php';
|
||||
require_once 'HTMLPurifier/AttrDef/MultiLength.php';
|
||||
require_once 'HTMLPurifier/AttrDef/NumberSpan.php';
|
||||
require_once 'HTMLPurifier/AttrTransform.php';
|
||||
require_once 'HTMLPurifier/AttrTransform/Lang.php';
|
||||
require_once 'HTMLPurifier/AttrTransform/TextAlign.php';
|
||||
@@ -290,17 +291,26 @@ class HTMLPurifier_Definition
|
||||
$this->info['table']->attr['border'] = new HTMLPurifier_AttrDef_Pixels();
|
||||
|
||||
$e_Length = new HTMLPurifier_AttrDef_Length();
|
||||
$this->info['table']->attr['cellpadding'] = $e_Length;
|
||||
$this->info['table']->attr['cellspacing'] = $e_Length;
|
||||
$this->info['table']->attr['width'] = $e_Length;
|
||||
$this->setAttrForTableElements('charoff', $e_Length);
|
||||
$this->info['img']->attr['height'] = $e_Length;
|
||||
$this->info['table']->attr['cellpadding'] =
|
||||
$this->info['table']->attr['cellspacing'] =
|
||||
$this->info['table']->attr['width'] =
|
||||
$this->info['img']->attr['height'] =
|
||||
$this->info['img']->attr['width'] = $e_Length;
|
||||
$this->setAttrForTableElements('charoff', $e_Length);
|
||||
|
||||
$e_MultiLength = new HTMLPurifier_AttrDef_MultiLength();
|
||||
$this->info['col']->attr['width'] = $e_MultiLength;
|
||||
$this->info['col']->attr['width'] =
|
||||
$this->info['colgroup']->attr['width'] = $e_MultiLength;
|
||||
|
||||
$e__NumberSpan = new HTMLPurifier_AttrDef_NumberSpan();
|
||||
$this->info['colgroup']->attr['span'] =
|
||||
$this->info['col']->attr['span'] =
|
||||
$this->info['td']->attr['rowspan'] =
|
||||
$this->info['th']->attr['rowspan'] =
|
||||
$this->info['td']->attr['colspan'] =
|
||||
$this->info['th']->attr['colspan'] = $e__NumberSpan;
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// UNIMP : info_tag_transform : transformations of tags
|
||||
|
||||
|
Reference in New Issue
Block a user