mirror of
https://github.com/ezyang/htmlpurifier.git
synced 2024-11-08 06:48:42 +00:00
[1.6.1] Transformation of font's size attribute now handles super-large numbers
git-svn-id: http://htmlpurifier.org/svnroot/htmlpurifier/trunk@1020 48356398-32a2-884e-a903-53898d9a118a
This commit is contained in:
parent
92ea74cba2
commit
bd6071cb3b
1
NEWS
1
NEWS
@ -30,6 +30,7 @@ NEWS ( CHANGELOG and HISTORY ) HTMLPurifier
|
||||
! XHTML 1.1 mode now sort-of works without any fatal errors, and
|
||||
lang is now moved over to xml:lang.
|
||||
! Attribute transformation smoketest available at smoketests/attrTransform.php
|
||||
! Transformation of font's size attribute now handles super-large numbers
|
||||
- Possibly fatal bug with __autoload() fixed in module manager
|
||||
- Invert HTMLModuleManager->addModule() processing order to check
|
||||
prefixes first and then the literal module
|
||||
|
@ -20,6 +20,7 @@ class HTMLPurifier_TagTransform_Font extends HTMLPurifier_TagTransform
|
||||
var $transform_to = 'span';
|
||||
|
||||
var $_size_lookup = array(
|
||||
'0' => 'xx-small',
|
||||
'1' => 'xx-small',
|
||||
'2' => 'small',
|
||||
'3' => 'medium',
|
||||
@ -28,9 +29,10 @@ class HTMLPurifier_TagTransform_Font extends HTMLPurifier_TagTransform
|
||||
'6' => 'xx-large',
|
||||
'7' => '300%',
|
||||
'-1' => 'smaller',
|
||||
'+1' => 'larger',
|
||||
'-2' => '60%',
|
||||
'+1' => 'larger',
|
||||
'+2' => '150%',
|
||||
'+3' => '200%',
|
||||
'+4' => '300%'
|
||||
);
|
||||
|
||||
@ -58,6 +60,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 (isset($this->_size_lookup[$attr['size']])) {
|
||||
$prepend_style .= 'font-size:' .
|
||||
$this->_size_lookup[$attr['size']] . ';';
|
||||
|
@ -10,7 +10,8 @@
|
||||
<sample><![CDATA[<font face="Arial">Arial</font>]]></sample>
|
||||
</group>
|
||||
<group title="font.size">
|
||||
<sample><![CDATA[<font size="-99">-99</font>]]></sample>
|
||||
<sample><![CDATA[<font size="-2">-2</font>]]></sample>
|
||||
<sample><![CDATA[<font size="-1">-1</font>]]></sample>
|
||||
<sample><![CDATA[<font size="0">0</font>]]></sample>
|
||||
<sample><![CDATA[<font size="1">1</font>]]></sample>
|
||||
<sample><![CDATA[<font size="2">2</font>]]></sample>
|
||||
@ -20,7 +21,11 @@
|
||||
<sample><![CDATA[<font size="6">6</font>]]></sample>
|
||||
<sample><![CDATA[<font size="7">7</font>]]></sample>
|
||||
<sample><![CDATA[<font size="8">8</font>]]></sample>
|
||||
<sample><![CDATA[<font size="99">99</font>]]></sample>
|
||||
<sample><![CDATA[<font size="+1">+1</font>]]></sample>
|
||||
<sample><![CDATA[<font size="+2">+2</font>]]></sample>
|
||||
<sample><![CDATA[<font size="+3">+3</font>]]></sample>
|
||||
<sample><![CDATA[<font size="+4">+4</font>]]></sample>
|
||||
<sample><![CDATA[<font size="+5">+5</font>]]></sample>
|
||||
</group>
|
||||
<group title="center">
|
||||
<sample><![CDATA[<center>Centered</center>]]></sample>
|
||||
|
Loading…
Reference in New Issue
Block a user