From bd6071cb3b7106575f705d65da828eb7eee979e1 Mon Sep 17 00:00:00 2001 From: "Edward Z. Yang" Date: Sat, 5 May 2007 18:56:45 +0000 Subject: [PATCH] [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 --- NEWS | 1 + library/HTMLPurifier/TagTransform/Font.php | 13 ++++++++++++- smoketests/attrTransform.xml | 9 +++++++-- 3 files changed, 20 insertions(+), 3 deletions(-) diff --git a/NEWS b/NEWS index e3a3ef73..55448f41 100644 --- a/NEWS +++ b/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 diff --git a/library/HTMLPurifier/TagTransform/Font.php b/library/HTMLPurifier/TagTransform/Font.php index ae6d7838..dedaf8b2 100644 --- a/library/HTMLPurifier/TagTransform/Font.php +++ b/library/HTMLPurifier/TagTransform/Font.php @@ -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']] . ';'; diff --git a/smoketests/attrTransform.xml b/smoketests/attrTransform.xml index 966d11a4..12dbe52e 100644 --- a/smoketests/attrTransform.xml +++ b/smoketests/attrTransform.xml @@ -10,7 +10,8 @@ Arial]]> - -99]]> + -2]]> + -1]]> 0]]> 1]]> 2]]> @@ -20,7 +21,11 @@ 6]]> 7]]> 8]]> - 99]]> + +1]]> + +2]]> + +3]]> + +4]]> + +5]]> Centered]]>