0
0
mirror of https://github.com/ezyang/htmlpurifier.git synced 2024-09-18 18:25:18 +00:00

Fix E_NOTICE from indexing into empty string.

Signed-off-by: Edward Z. Yang <ezyang@mit.edu>
This commit is contained in:
Edward Z. Yang 2011-03-17 17:33:11 +00:00
parent b4469f17aa
commit ee9c70ab7f
3 changed files with 15 additions and 7 deletions

2
NEWS
View File

@ -43,6 +43,8 @@ NEWS ( CHANGELOG and HISTORY ) HTMLPurifier
Reported by Neike Taika-Tessaro.
- Fix missing numeric entities on DirectLex; thanks Neike Taika-Tessaro
for reporting.
- Fix harmless notice from indexing into empty string. Thanks Matthijs
Kooijman <matthijs@stdin.nl> for reporting.
4.2.0, released 2010-09-15
! Added %Core.RemoveProcessingInstructions, which lets you remove

View File

@ -63,13 +63,15 @@ class HTMLPurifier_TagTransform_Font extends HTMLPurifier_TagTransform
// handle size transform
if (isset($attr['size'])) {
// normalize large numbers
if ($attr['size']{0} == '+' || $attr['size']{0} == '-') {
$size = (int) $attr['size'];
if ($size < -2) $attr['size'] = '-2';
if ($size > 4) $attr['size'] = '+4';
} else {
$size = (int) $attr['size'];
if ($size > 7) $attr['size'] = '7';
if ($attr['size'] !== '') {
if ($attr['size']{0} == '+' || $attr['size']{0} == '-') {
$size = (int) $attr['size'];
if ($size < -2) $attr['size'] = '-2';
if ($size > 4) $attr['size'] = '+4';
} else {
$size = (int) $attr['size'];
if ($size > 7) $attr['size'] = '7';
}
}
if (isset($this->_size_lookup[$attr['size']])) {
$prepend_style .= 'font-size:' .

View File

@ -162,6 +162,10 @@ class HTMLPurifier_TagTransformTest extends HTMLPurifier_Harness
$this->assertSizeToStyle($transformer, '+3', '200%');
$this->assertSizeToStyle($transformer, '+4', '300%');
$this->assertSizeToStyle($transformer, '+5', '300%');
$this->assertTransformation(
$transformer, 'font', array('size' => ''),
'span', array()
);
// test multiple transforms, the alphabetical ordering is important
$this->assertTransformation(