mirror of
https://github.com/ezyang/htmlpurifier.git
synced 2025-01-03 05:11:52 +00:00
[1.7.0] Complete Legacy element and attribute native support.
git-svn-id: http://htmlpurifier.org/svnroot/htmlpurifier/trunk@1115 48356398-32a2-884e-a903-53898d9a118a
This commit is contained in:
parent
9c5f01a0cf
commit
426fbd1f97
1
NEWS
1
NEWS
@ -28,6 +28,7 @@ NEWS ( CHANGELOG and HISTORY ) HTMLPurifier
|
|||||||
! Configuration directives that accept hashes now allow new string
|
! Configuration directives that accept hashes now allow new string
|
||||||
format: key1:value1,key2:value2
|
format: key1:value1,key2:value2
|
||||||
! ConfigDoc now factored into OOP design
|
! ConfigDoc now factored into OOP design
|
||||||
|
! All deprecated elements now natively supported
|
||||||
- Deprecated and removed EnableRedundantUTF8Cleaning. It didn't even work!
|
- Deprecated and removed EnableRedundantUTF8Cleaning. It didn't even work!
|
||||||
. Unit test for ElementDef created, ElementDef behavior modified to
|
. Unit test for ElementDef created, ElementDef behavior modified to
|
||||||
be more flexible
|
be more flexible
|
||||||
|
7
TODO
7
TODO
@ -15,10 +15,6 @@ TODO List
|
|||||||
- Get all AttrTypes into string form
|
- Get all AttrTypes into string form
|
||||||
# Clean up HTMLDefinition caching, need easy cache invalidation,
|
# Clean up HTMLDefinition caching, need easy cache invalidation,
|
||||||
versioning of caches, etc.
|
versioning of caches, etc.
|
||||||
# Implement all deprecated tags and attributes
|
|
||||||
# Create parsing/standards compliance smoketest
|
|
||||||
# Reorganize Unit Tests
|
|
||||||
- Refactor loop tests (esp. AttrDef_URI)
|
|
||||||
- Parse TinyMCE-style whitelist into our %HTML.Allow* whitelists
|
- Parse TinyMCE-style whitelist into our %HTML.Allow* whitelists
|
||||||
|
|
||||||
1.8 release [Refactor, refactor!]
|
1.8 release [Refactor, refactor!]
|
||||||
@ -86,6 +82,9 @@ Ongoing
|
|||||||
- WordPress (mostly written, needs beta-testing)
|
- WordPress (mostly written, needs beta-testing)
|
||||||
- eFiction
|
- eFiction
|
||||||
- more! (look for ones that use WYSIWYGs)
|
- more! (look for ones that use WYSIWYGs)
|
||||||
|
- Complete basic smoketests
|
||||||
|
- Reorganize Unit Tests
|
||||||
|
- Refactor loop tests (esp. AttrDef_URI)
|
||||||
|
|
||||||
Unknown release (on a scratch-an-itch basis)
|
Unknown release (on a scratch-an-itch basis)
|
||||||
? Semi-lossy dumb alternate character encoding transfor
|
? Semi-lossy dumb alternate character encoding transfor
|
||||||
|
@ -47,11 +47,18 @@ class HTMLPurifier_AttrDef_Enum extends HTMLPurifier_AttrDef
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param $string In form of comma-delimited list of case-insensitive
|
* @param $string In form of comma-delimited list of case-insensitive
|
||||||
* valid values. Example: "foo,bar,baz"
|
* valid values. Example: "foo,bar,baz". Prepend "s:" to make
|
||||||
|
* case sensitive
|
||||||
*/
|
*/
|
||||||
function make($string) {
|
function make($string) {
|
||||||
|
if (strlen($string) > 2 && $string[0] == 's' && $string[1] == ':') {
|
||||||
|
$string = substr($string, 2);
|
||||||
|
$sensitive = true;
|
||||||
|
} else {
|
||||||
|
$sensitive = false;
|
||||||
|
}
|
||||||
$values = explode(',', $string);
|
$values = explode(',', $string);
|
||||||
return new HTMLPurifier_AttrDef_Enum($values);
|
return new HTMLPurifier_AttrDef_Enum($values, $sensitive);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -139,9 +139,13 @@ class HTMLPurifier_HTMLModule
|
|||||||
* @return Reference to created element
|
* @return Reference to created element
|
||||||
*/
|
*/
|
||||||
function &addBlankElement($element) {
|
function &addBlankElement($element) {
|
||||||
$this->elements[] = $element;
|
if (!isset($this->info[$element])) {
|
||||||
$this->info[$element] = new HTMLPurifier_ElementDef();
|
$this->elements[] = $element;
|
||||||
$this->info[$element]->standalone = false;
|
$this->info[$element] = new HTMLPurifier_ElementDef();
|
||||||
|
$this->info[$element]->standalone = false;
|
||||||
|
} else {
|
||||||
|
trigger_error("Definition for $element already exists in module, cannot redefine");
|
||||||
|
}
|
||||||
return $this->info[$element];
|
return $this->info[$element];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -51,12 +51,6 @@ class HTMLPurifier_HTMLModule_Legacy extends HTMLPurifier_HTMLModule
|
|||||||
|
|
||||||
// setup modifications to old elements
|
// setup modifications to old elements
|
||||||
|
|
||||||
$li =& $this->addBlankElement('li');
|
|
||||||
$li->attr['value'] = new HTMLPurifier_AttrDef_Integer();
|
|
||||||
|
|
||||||
$ol =& $this->addBlankElement('ol');
|
|
||||||
$ol->attr['start'] = new HTMLPurifier_AttrDef_Integer();
|
|
||||||
|
|
||||||
$align = 'Enum#left,right,center,justify';
|
$align = 'Enum#left,right,center,justify';
|
||||||
|
|
||||||
$address =& $this->addBlankElement('address');
|
$address =& $this->addBlankElement('address');
|
||||||
@ -86,7 +80,59 @@ class HTMLPurifier_HTMLModule_Legacy extends HTMLPurifier_HTMLModule
|
|||||||
$h->attr['align'] = $align;
|
$h->attr['align'] = $align;
|
||||||
}
|
}
|
||||||
|
|
||||||
// to be continued...
|
$hr =& $this->addBlankElement('hr');
|
||||||
|
$hr->attr['align'] = $align;
|
||||||
|
$hr->attr['noshade'] = 'Bool#noshade';
|
||||||
|
$hr->attr['size'] = 'Pixels';
|
||||||
|
$hr->attr['width'] = 'Length';
|
||||||
|
|
||||||
|
$img =& $this->addBlankElement('img');
|
||||||
|
$img->attr['align'] = 'Enum#top,middle,bottom,left,right';
|
||||||
|
$img->attr['border'] = 'Pixels';
|
||||||
|
$img->attr['hspace'] = 'Pixels';
|
||||||
|
$img->attr['vspace'] = 'Pixels';
|
||||||
|
|
||||||
|
// figure out this integer business
|
||||||
|
|
||||||
|
$li =& $this->addBlankElement('li');
|
||||||
|
$li->attr['value'] = new HTMLPurifier_AttrDef_Integer();
|
||||||
|
$li->attr['type'] = 'Enum#s:1,i,I,a,A,disc,square,circle';
|
||||||
|
|
||||||
|
$ol =& $this->addBlankElement('ol');
|
||||||
|
$ol->attr['compact'] = 'Bool#compact';
|
||||||
|
$ol->attr['start'] = new HTMLPurifier_AttrDef_Integer();
|
||||||
|
$ol->attr['type'] = 'Enum#s:1,i,I,a,A';
|
||||||
|
|
||||||
|
$p =& $this->addBlankElement('p');
|
||||||
|
$p->attr['align'] = $align;
|
||||||
|
|
||||||
|
$pre =& $this->addBlankElement('pre');
|
||||||
|
$pre->attr['width'] = 'Number';
|
||||||
|
|
||||||
|
// script omitted
|
||||||
|
|
||||||
|
$table =& $this->addBlankElement('table');
|
||||||
|
$table->attr['align'] = 'Enum#left,center,right';
|
||||||
|
$table->attr['bgcolor'] = 'Color';
|
||||||
|
|
||||||
|
$tr =& $this->addBlankElement('tr');
|
||||||
|
$tr->attr['bgcolor'] = 'Color';
|
||||||
|
|
||||||
|
$th =& $this->addBlankElement('th');
|
||||||
|
$th->attr['bgcolor'] = 'Color';
|
||||||
|
$th->attr['height'] = 'Length';
|
||||||
|
$th->attr['nowrap'] = 'Bool#nowrap';
|
||||||
|
$th->attr['width'] = 'Length';
|
||||||
|
|
||||||
|
$td =& $this->addBlankElement('td');
|
||||||
|
$td->attr['bgcolor'] = 'Color';
|
||||||
|
$td->attr['height'] = 'Length';
|
||||||
|
$td->attr['nowrap'] = 'Bool#nowrap';
|
||||||
|
$td->attr['width'] = 'Length';
|
||||||
|
|
||||||
|
$ul =& $this->addBlankElement('ul');
|
||||||
|
$ul->attr['compact'] = 'Bool#compact';
|
||||||
|
$ul->attr['type'] = 'Enum#square,disc,circle';
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -23,10 +23,49 @@ hr[noshade='noshade'],
|
|||||||
hr[width='50'],
|
hr[width='50'],
|
||||||
hr[size='50'],
|
hr[size='50'],
|
||||||
|
|
||||||
|
img[align='right'],
|
||||||
|
img[border='3'],
|
||||||
|
img[hspace='5'],
|
||||||
|
img[vspace='5'],
|
||||||
|
|
||||||
|
input[align='right'],
|
||||||
|
legend[align='center'],
|
||||||
|
|
||||||
|
li[type='A'],
|
||||||
|
li[value='5'],
|
||||||
|
|
||||||
|
ol[compact='compact'],
|
||||||
|
ol[start='3'],
|
||||||
|
ol[type='I'],
|
||||||
|
|
||||||
|
p[align='right'],
|
||||||
|
|
||||||
|
pre[width='50'],
|
||||||
|
|
||||||
|
table[align='right'],
|
||||||
|
table[bgcolor='#0000FF'],
|
||||||
|
|
||||||
|
tr[bgcolor='#0000FF'],
|
||||||
|
|
||||||
|
td[bgcolor='#0000FF'],
|
||||||
|
td[height='50'],
|
||||||
|
td[nowrap='nowrap'],
|
||||||
|
td[width='200'],
|
||||||
|
|
||||||
|
th[bgcolor='#0000FF'],
|
||||||
|
th[height='50'],
|
||||||
|
th[nowrap='nowrap'],
|
||||||
|
th[width='200'],
|
||||||
|
|
||||||
|
ul[compact='compact'],
|
||||||
|
ul[type='square'],
|
||||||
|
|
||||||
.insert-declarations-above
|
.insert-declarations-above
|
||||||
{background:#008000; color:#FFF; font-weight:bold;}
|
{background:#008000; color:#FFF; font-weight:bold;}
|
||||||
|
|
||||||
font {background:#BFB;}
|
font {background:#BFB;}
|
||||||
u {border:1px solid #000;}
|
u {border:1px solid #000;}
|
||||||
hr {height:1em;}
|
hr {height:1em;}
|
||||||
hr[size='50'] {height:50px;}
|
hr[size='50'] {height:50px;}
|
||||||
|
img[border='3'] {border: 3px solid #000;}
|
||||||
|
li[type='a'], li[value='5'] {color:#DDD;}
|
||||||
|
@ -76,26 +76,49 @@ hr@width
|
|||||||
hr@size
|
hr@size
|
||||||
<hr size="50" />
|
<hr size="50" />
|
||||||
|
|
||||||
|
<img src="" alt="img@align" align="right" /> |
|
||||||
|
<img src="" alt="img@border" border="3" /> |
|
||||||
|
<img src="" alt="img@hspace" hspace="5" /> |
|
||||||
|
<img src="" alt="img@vspace" vspace="5" />
|
||||||
|
|
||||||
|
<!-- needs context -->
|
||||||
|
<input align="right" />
|
||||||
|
<legend align="center">Legend</legend>
|
||||||
|
|
||||||
|
<ol>
|
||||||
|
<li type="A">li@type (ensure that it's a capital A)</li>
|
||||||
|
<li value="5">li@value</li>
|
||||||
|
</ol>
|
||||||
|
|
||||||
|
<ol compact="compact"><li>ol@compact</li></ol>
|
||||||
|
<ol start="3"><li>ol@start</li></ol>
|
||||||
|
<ol type="I"><li>ol@type</li></ol>
|
||||||
|
|
||||||
|
<p align="right">p@align</p>
|
||||||
|
|
||||||
|
<pre width="50">pre@width</pre>
|
||||||
|
|
||||||
|
<script language="JavaScript">document.writeln('script');</script>
|
||||||
|
|
||||||
|
<table align="right"><tr><td>table@align</td></tr></table>
|
||||||
|
<table bgcolor="#0000FF"><tr><td>table@bgcolor</td></tr></table>
|
||||||
|
|
||||||
|
<table><tr bgcolor="#0000FF"><td>tr@bgcolor</td></tr></table>
|
||||||
|
|
||||||
|
<table><tr><td bgcolor="#0000FF">td@bgcolor</td></tr></table>
|
||||||
|
<table><tr><td height="50">td@height</td></tr></table>
|
||||||
|
<table><tr><td nowrap="nowrap">td@nowrap</td></tr></table>
|
||||||
|
<table><tr><td width="200">td@width</td></tr></table>
|
||||||
|
|
||||||
|
<table><tr><th bgcolor="#0000FF">th@bgcolor</th></tr></table>
|
||||||
|
<table><tr><th height="50">th@height</th></tr></table>
|
||||||
|
<table><tr><th nowrap="nowrap">th@nowrap</th></tr></table>
|
||||||
|
<table><tr><th width="200">th@width</th></tr></table>
|
||||||
|
|
||||||
|
<ul compact="compact"><li>ul@compact</li></ul>
|
||||||
|
<ul type="square"><li>ul@square</li></ul>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!--
|
|
||||||
|
|
||||||
img& align ("top" | "middle" | "bottom" | "left" | "right"), border (Pixels), hspace (Pixels), vspace (Pixels)
|
|
||||||
input& align ("top" | "middle" | "bottom" | "left" | "right") When the Basic Forms or Forms Module is selected.
|
|
||||||
legend& align ("left" | "center" | "right" | "justify") When the Forms Module is selected.
|
|
||||||
li& type (CDATA), value (Number)
|
|
||||||
ol& compact ("compact"), start (Number), type (CDATA)
|
|
||||||
p& align ("left" | "center" | "right", "justify")
|
|
||||||
pre& width (Number)
|
|
||||||
script& language (CDATA) When the Scripting module is selected.
|
|
||||||
table& align ("left" | "center" | "right"), bgcolor (Color) When the Tables module is selected.
|
|
||||||
tr& bgcolor (Color) When the Tables module is selected.
|
|
||||||
th& bgcolor (Color), height (Length) nowrap ("nowrap"), width (Length) When the Tables module is selected.
|
|
||||||
td& bgcolor (Color), height (Length) nowrap ("nowrap"), width (Length) When the Tables module is selected.
|
|
||||||
ul& compact ("compact"), type (CDATA)
|
|
||||||
|
|
||||||
-->
|
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
@ -25,9 +25,14 @@ class HTMLPurifier_AttrDef_EnumTest extends HTMLPurifier_AttrDefHarness
|
|||||||
|
|
||||||
function test_make() {
|
function test_make() {
|
||||||
$factory = new HTMLPurifier_AttrDef_Enum();
|
$factory = new HTMLPurifier_AttrDef_Enum();
|
||||||
|
|
||||||
$def = $factory->make('foo,bar');
|
$def = $factory->make('foo,bar');
|
||||||
$def2 = new HTMLPurifier_AttrDef_Enum(array('foo', 'bar'));
|
$def2 = new HTMLPurifier_AttrDef_Enum(array('foo', 'bar'));
|
||||||
$this->assertIdentical($def, $def2);
|
$this->assertIdentical($def, $def2);
|
||||||
|
|
||||||
|
$def = $factory->make('s:foo,BAR');
|
||||||
|
$def2 = new HTMLPurifier_AttrDef_Enum(array('foo', 'BAR'), true);
|
||||||
|
$this->assertIdentical($def, $def2);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user