From c05eebee15e3ddb4e2d36195e2d3d87738a089cd Mon Sep 17 00:00:00 2001 From: "Edward Z. Yang" Date: Wed, 14 Feb 2007 20:38:51 +0000 Subject: [PATCH] [1.5.0] AttrDef partitioned into HTML, CSS and URI segments. Also, some minor bugs with MultiLength fixed. git-svn-id: http://htmlpurifier.org/svnroot/htmlpurifier/trunk@747 48356398-32a2-884e-a903-53898d9a118a --- NEWS | 1 + .../AttrDef/{ => CSS}/Background.php | 4 +- .../AttrDef/{ => CSS}/BackgroundPosition.php | 12 +- .../HTMLPurifier/AttrDef/{ => CSS}/Border.php | 4 +- .../HTMLPurifier/AttrDef/{ => CSS}/Color.php | 2 +- .../AttrDef/{ => CSS}/Composite.php | 4 +- .../HTMLPurifier/AttrDef/{ => CSS}/Font.php | 4 +- .../AttrDef/{ => CSS}/FontFamily.php | 2 +- .../AttrDef/{CSSLength.php => CSS/Length.php} | 9 +- .../AttrDef/{ => CSS}/ListStyle.php | 6 +- .../AttrDef/{ => CSS}/Multiple.php | 4 +- .../HTMLPurifier/AttrDef/{ => CSS}/Number.php | 4 +- .../AttrDef/{ => CSS}/Percentage.php | 10 +- .../AttrDef/{ => CSS}/TextDecoration.php | 2 +- .../AttrDef/{CSSURI.php => CSS/URI.php} | 4 +- .../HTMLPurifier/AttrDef/{ => HTML}/ID.php | 2 +- .../AttrDef/{ => HTML}/Length.php | 8 +- .../AttrDef/{ => HTML}/MultiLength.php | 10 +- .../AttrDef/{ => HTML}/Nmtokens.php | 2 +- .../AttrDef/{ => HTML}/Pixels.php | 2 +- library/HTMLPurifier/AttrDef/URI.php | 4 +- .../HTMLPurifier/AttrDef/{ => URI}/Email.php | 2 +- .../AttrDef/{ => URI}/Email/SimpleCheck.php | 4 +- .../HTMLPurifier/AttrDef/{ => URI}/Host.php | 16 +-- .../HTMLPurifier/AttrDef/{ => URI}/IPv4.php | 4 +- .../HTMLPurifier/AttrDef/{ => URI}/IPv6.php | 4 +- library/HTMLPurifier/AttrTypes.php | 36 +++--- library/HTMLPurifier/CSSDefinition.php | 116 +++++++++--------- library/HTMLPurifier/HTMLDefinition.php | 2 +- .../{ => CSS}/BackgroundPositionTest.php | 6 +- .../AttrDef/{ => CSS}/BackgroundTest.php | 7 +- .../AttrDef/{ => CSS}/BorderTest.php | 8 +- .../AttrDef/{ => CSS}/ColorTest.php | 6 +- .../AttrDef/{ => CSS}/CompositeTest.php | 16 +-- .../AttrDef/{ => CSS}/FontFamilyTest.php | 6 +- .../AttrDef/{ => CSS}/FontTest.php | 7 +- .../{CSSLengthTest.php => CSS/LengthTest.php} | 8 +- .../AttrDef/{ => CSS}/ListStyleTest.php | 7 +- .../AttrDef/{ => CSS}/MultipleTest.php | 6 +- .../AttrDef/{ => CSS}/NumberTest.php | 8 +- .../AttrDef/{ => CSS}/PercentageTest.php | 6 +- .../AttrDef/{ => CSS}/TextDecorationTest.php | 6 +- .../{CSSURITest.php => CSS/URITest.php} | 6 +- .../AttrDef/Email/SimpleCheckTest.php | 16 --- .../AttrDef/{ => HTML}/IDTest.php | 12 +- .../AttrDef/{ => HTML}/LengthTest.php | 8 +- .../AttrDef/{ => HTML}/MultiLengthTest.php | 10 +- .../AttrDef/{ => HTML}/NmtokensTest.php | 7 +- .../AttrDef/{ => HTML}/PixelsTest.php | 6 +- .../AttrDef/URI/Email/SimpleCheckTest.php | 16 +++ .../AttrDef/{ => URI}/EmailHarness.php | 4 +- .../AttrDef/{ => URI}/HostTest.php | 6 +- .../AttrDef/{ => URI}/IPv4Test.php | 6 +- .../AttrDef/{ => URI}/IPv6Test.php | 6 +- tests/test_files.php | 115 ++++++++--------- 55 files changed, 301 insertions(+), 298 deletions(-) rename library/HTMLPurifier/AttrDef/{ => CSS}/Background.php (95%) rename library/HTMLPurifier/AttrDef/{ => CSS}/BackgroundPosition.php (89%) rename library/HTMLPurifier/AttrDef/{ => CSS}/Border.php (90%) rename library/HTMLPurifier/AttrDef/{ => CSS}/Color.php (97%) rename library/HTMLPurifier/AttrDef/{ => CSS}/Composite.php (88%) rename library/HTMLPurifier/AttrDef/{ => CSS}/Font.php (98%) rename library/HTMLPurifier/AttrDef/{ => CSS}/FontFamily.php (96%) rename library/HTMLPurifier/AttrDef/{CSSLength.php => CSS/Length.php} (81%) rename library/HTMLPurifier/AttrDef/{ => CSS}/ListStyle.php (91%) rename library/HTMLPurifier/AttrDef/{ => CSS}/Multiple.php (92%) rename library/HTMLPurifier/AttrDef/{ => CSS}/Number.php (90%) rename library/HTMLPurifier/AttrDef/{ => CSS}/Percentage.php (68%) rename library/HTMLPurifier/AttrDef/{ => CSS}/TextDecoration.php (92%) rename library/HTMLPurifier/AttrDef/{CSSURI.php => CSS/URI.php} (94%) rename library/HTMLPurifier/AttrDef/{ => HTML}/ID.php (98%) rename library/HTMLPurifier/AttrDef/{ => HTML}/Length.php (77%) rename library/HTMLPurifier/AttrDef/{ => HTML}/MultiLength.php (75%) rename library/HTMLPurifier/AttrDef/{ => HTML}/Nmtokens.php (95%) rename library/HTMLPurifier/AttrDef/{ => HTML}/Pixels.php (92%) rename library/HTMLPurifier/AttrDef/{ => URI}/Email.php (75%) rename library/HTMLPurifier/AttrDef/{ => URI}/Email/SimpleCheck.php (79%) rename library/HTMLPurifier/AttrDef/{ => URI}/Host.php (71%) rename library/HTMLPurifier/AttrDef/{ => URI}/IPv4.php (84%) rename library/HTMLPurifier/AttrDef/{ => URI}/IPv6.php (95%) rename tests/HTMLPurifier/AttrDef/{ => CSS}/BackgroundPositionTest.php (90%) rename tests/HTMLPurifier/AttrDef/{ => CSS}/BackgroundTest.php (52%) rename tests/HTMLPurifier/AttrDef/{ => CSS}/BorderTest.php (50%) rename tests/HTMLPurifier/AttrDef/{ => CSS}/ColorTest.php (83%) rename tests/HTMLPurifier/AttrDef/{ => CSS}/CompositeTest.php (83%) rename tests/HTMLPurifier/AttrDef/{ => CSS}/FontFamilyTest.php (69%) rename tests/HTMLPurifier/AttrDef/{ => CSS}/FontTest.php (79%) rename tests/HTMLPurifier/AttrDef/{CSSLengthTest.php => CSS/LengthTest.php} (75%) rename tests/HTMLPurifier/AttrDef/{ => CSS}/ListStyleTest.php (77%) rename tests/HTMLPurifier/AttrDef/{ => CSS}/MultipleTest.php (77%) rename tests/HTMLPurifier/AttrDef/{ => CSS}/NumberTest.php (73%) rename tests/HTMLPurifier/AttrDef/{ => CSS}/PercentageTest.php (66%) rename tests/HTMLPurifier/AttrDef/{ => CSS}/TextDecorationTest.php (72%) rename tests/HTMLPurifier/AttrDef/{CSSURITest.php => CSS/URITest.php} (83%) delete mode 100644 tests/HTMLPurifier/AttrDef/Email/SimpleCheckTest.php rename tests/HTMLPurifier/AttrDef/{ => HTML}/IDTest.php (88%) rename tests/HTMLPurifier/AttrDef/{ => HTML}/LengthTest.php (67%) rename tests/HTMLPurifier/AttrDef/{ => HTML}/MultiLengthTest.php (56%) rename tests/HTMLPurifier/AttrDef/{ => HTML}/NmtokensTest.php (75%) rename tests/HTMLPurifier/AttrDef/{ => HTML}/PixelsTest.php (79%) create mode 100644 tests/HTMLPurifier/AttrDef/URI/Email/SimpleCheckTest.php rename tests/HTMLPurifier/AttrDef/{ => URI}/EmailHarness.php (87%) rename tests/HTMLPurifier/AttrDef/{ => URI}/HostTest.php (65%) rename tests/HTMLPurifier/AttrDef/{ => URI}/IPv4Test.php (78%) rename tests/HTMLPurifier/AttrDef/{ => URI}/IPv6Test.php (91%) diff --git a/NEWS b/NEWS index e39b050a..f82896eb 100644 --- a/NEWS +++ b/NEWS @@ -29,6 +29,7 @@ NEWS ( CHANGELOG and HISTORY ) HTMLPurifier . Removed redundant "exclusionary" definitions from DTD roster . StrictBlockquote now requires a construction parameter as if it were an Required ChildDef, this is the "real" set of allowed elements +. AttrDef partitioned into HTML, CSS and URI segments 1.4.2, unknown release date ! docs/enduser-utf8.html explains how to use UTF-8 and HTML Purifier diff --git a/library/HTMLPurifier/AttrDef/Background.php b/library/HTMLPurifier/AttrDef/CSS/Background.php similarity index 95% rename from library/HTMLPurifier/AttrDef/Background.php rename to library/HTMLPurifier/AttrDef/CSS/Background.php index 1db3f88d..42d8bcf0 100644 --- a/library/HTMLPurifier/AttrDef/Background.php +++ b/library/HTMLPurifier/AttrDef/CSS/Background.php @@ -7,7 +7,7 @@ require_once 'HTMLPurifier/CSSDefinition.php'; * Validates shorthand CSS property background. * @warning Does not support url tokens that have internal spaces. */ -class HTMLPurifier_AttrDef_Background extends HTMLPurifier_AttrDef +class HTMLPurifier_AttrDef_CSS_Background extends HTMLPurifier_AttrDef { /** @@ -16,7 +16,7 @@ class HTMLPurifier_AttrDef_Background extends HTMLPurifier_AttrDef */ var $info; - function HTMLPurifier_AttrDef_Background($config) { + function HTMLPurifier_AttrDef_CSS_Background($config) { $def = $config->getCSSDefinition(); $this->info['background-color'] = $def->info['background-color']; $this->info['background-image'] = $def->info['background-image']; diff --git a/library/HTMLPurifier/AttrDef/BackgroundPosition.php b/library/HTMLPurifier/AttrDef/CSS/BackgroundPosition.php similarity index 89% rename from library/HTMLPurifier/AttrDef/BackgroundPosition.php rename to library/HTMLPurifier/AttrDef/CSS/BackgroundPosition.php index 0b59c403..77a3ddd6 100644 --- a/library/HTMLPurifier/AttrDef/BackgroundPosition.php +++ b/library/HTMLPurifier/AttrDef/CSS/BackgroundPosition.php @@ -1,8 +1,8 @@ length = new HTMLPurifier_AttrDef_CSSLength(); - $this->percentage = new HTMLPurifier_AttrDef_Percentage(); + function HTMLPurifier_AttrDef_CSS_BackgroundPosition() { + $this->length = new HTMLPurifier_AttrDef_CSS_Length(); + $this->percentage = new HTMLPurifier_AttrDef_CSS_Percentage(); } function validate($string, $config, &$context) { diff --git a/library/HTMLPurifier/AttrDef/Border.php b/library/HTMLPurifier/AttrDef/CSS/Border.php similarity index 90% rename from library/HTMLPurifier/AttrDef/Border.php rename to library/HTMLPurifier/AttrDef/CSS/Border.php index ecd016a3..583f14fd 100644 --- a/library/HTMLPurifier/AttrDef/Border.php +++ b/library/HTMLPurifier/AttrDef/CSS/Border.php @@ -5,7 +5,7 @@ require_once 'HTMLPurifier/AttrDef.php'; /** * Validates the border property as defined by CSS. */ -class HTMLPurifier_AttrDef_Border extends HTMLPurifier_AttrDef +class HTMLPurifier_AttrDef_CSS_Border extends HTMLPurifier_AttrDef { /** @@ -13,7 +13,7 @@ class HTMLPurifier_AttrDef_Border extends HTMLPurifier_AttrDef */ var $info = array(); - function HTMLPurifier_AttrDef_Border($config) { + function HTMLPurifier_AttrDef_CSS_Border($config) { $def = $config->getCSSDefinition(); $this->info['border-width'] = $def->info['border-width']; $this->info['border-style'] = $def->info['border-style']; diff --git a/library/HTMLPurifier/AttrDef/Color.php b/library/HTMLPurifier/AttrDef/CSS/Color.php similarity index 97% rename from library/HTMLPurifier/AttrDef/Color.php rename to library/HTMLPurifier/AttrDef/CSS/Color.php index 3948a19c..4e6a78ac 100644 --- a/library/HTMLPurifier/AttrDef/Color.php +++ b/library/HTMLPurifier/AttrDef/CSS/Color.php @@ -5,7 +5,7 @@ require_once 'HTMLPurifier/AttrDef.php'; /** * Validates Color as defined by CSS. */ -class HTMLPurifier_AttrDef_Color extends HTMLPurifier_AttrDef +class HTMLPurifier_AttrDef_CSS_Color extends HTMLPurifier_AttrDef { /** diff --git a/library/HTMLPurifier/AttrDef/Composite.php b/library/HTMLPurifier/AttrDef/CSS/Composite.php similarity index 88% rename from library/HTMLPurifier/AttrDef/Composite.php rename to library/HTMLPurifier/AttrDef/CSS/Composite.php index 7be0bd97..9d2803d2 100644 --- a/library/HTMLPurifier/AttrDef/Composite.php +++ b/library/HTMLPurifier/AttrDef/CSS/Composite.php @@ -9,7 +9,7 @@ * especially useful for CSS values, which often are a choice between * an enumerated set of predefined values or a flexible data type. */ -class HTMLPurifier_AttrDef_Composite extends HTMLPurifier_AttrDef +class HTMLPurifier_AttrDef_CSS_Composite extends HTMLPurifier_AttrDef { /** @@ -21,7 +21,7 @@ class HTMLPurifier_AttrDef_Composite extends HTMLPurifier_AttrDef /** * @param $defs List of HTMLPurifier_AttrDef objects */ - function HTMLPurifier_AttrDef_Composite($defs) { + function HTMLPurifier_AttrDef_CSS_Composite($defs) { $this->defs = $defs; } diff --git a/library/HTMLPurifier/AttrDef/Font.php b/library/HTMLPurifier/AttrDef/CSS/Font.php similarity index 98% rename from library/HTMLPurifier/AttrDef/Font.php rename to library/HTMLPurifier/AttrDef/CSS/Font.php index 7357e282..1b3b0905 100644 --- a/library/HTMLPurifier/AttrDef/Font.php +++ b/library/HTMLPurifier/AttrDef/CSS/Font.php @@ -5,7 +5,7 @@ require_once 'HTMLPurifier/AttrDef.php'; /** * Validates shorthand CSS property font. */ -class HTMLPurifier_AttrDef_Font extends HTMLPurifier_AttrDef +class HTMLPurifier_AttrDef_CSS_Font extends HTMLPurifier_AttrDef { /** @@ -30,7 +30,7 @@ class HTMLPurifier_AttrDef_Font extends HTMLPurifier_AttrDef 'status-bar' => true ); - function HTMLPurifier_AttrDef_Font($config) { + function HTMLPurifier_AttrDef_CSS_Font($config) { $def = $config->getCSSDefinition(); $this->info['font-style'] = $def->info['font-style']; $this->info['font-variant'] = $def->info['font-variant']; diff --git a/library/HTMLPurifier/AttrDef/FontFamily.php b/library/HTMLPurifier/AttrDef/CSS/FontFamily.php similarity index 96% rename from library/HTMLPurifier/AttrDef/FontFamily.php rename to library/HTMLPurifier/AttrDef/CSS/FontFamily.php index 32da724e..15cbbf39 100644 --- a/library/HTMLPurifier/AttrDef/FontFamily.php +++ b/library/HTMLPurifier/AttrDef/CSS/FontFamily.php @@ -7,7 +7,7 @@ require_once 'HTMLPurifier/AttrDef.php'; /** * Validates a font family list according to CSS spec */ -class HTMLPurifier_AttrDef_FontFamily extends HTMLPurifier_AttrDef +class HTMLPurifier_AttrDef_CSS_FontFamily extends HTMLPurifier_AttrDef { /** diff --git a/library/HTMLPurifier/AttrDef/CSSLength.php b/library/HTMLPurifier/AttrDef/CSS/Length.php similarity index 81% rename from library/HTMLPurifier/AttrDef/CSSLength.php rename to library/HTMLPurifier/AttrDef/CSS/Length.php index 50613a39..7da26a8f 100644 --- a/library/HTMLPurifier/AttrDef/CSSLength.php +++ b/library/HTMLPurifier/AttrDef/CSS/Length.php @@ -1,13 +1,12 @@ number_def = new HTMLPurifier_AttrDef_Number($non_negative); + function HTMLPurifier_AttrDef_CSS_Length($non_negative = false) { + $this->number_def = new HTMLPurifier_AttrDef_CSS_Number($non_negative); } function validate($length, $config, &$context) { diff --git a/library/HTMLPurifier/AttrDef/ListStyle.php b/library/HTMLPurifier/AttrDef/CSS/ListStyle.php similarity index 91% rename from library/HTMLPurifier/AttrDef/ListStyle.php rename to library/HTMLPurifier/AttrDef/CSS/ListStyle.php index b09ee354..2d2ed12d 100644 --- a/library/HTMLPurifier/AttrDef/ListStyle.php +++ b/library/HTMLPurifier/AttrDef/CSS/ListStyle.php @@ -6,16 +6,16 @@ require_once 'HTMLPurifier/AttrDef.php'; * Validates shorthand CSS property list-style. * @warning Does not support url tokens that have internal spaces. */ -class HTMLPurifier_AttrDef_ListStyle extends HTMLPurifier_AttrDef +class HTMLPurifier_AttrDef_CSS_ListStyle extends HTMLPurifier_AttrDef { /** * Local copy of component validators. - * @note See HTMLPurifier_AttrDef_Font::$info for a similar impl. + * @note See HTMLPurifier_AttrDef_CSS_Font::$info for a similar impl. */ var $info; - function HTMLPurifier_AttrDef_ListStyle($config) { + function HTMLPurifier_AttrDef_CSS_ListStyle($config) { $def = $config->getCSSDefinition(); $this->info['list-style-type'] = $def->info['list-style-type']; $this->info['list-style-position'] = $def->info['list-style-position']; diff --git a/library/HTMLPurifier/AttrDef/Multiple.php b/library/HTMLPurifier/AttrDef/CSS/Multiple.php similarity index 92% rename from library/HTMLPurifier/AttrDef/Multiple.php rename to library/HTMLPurifier/AttrDef/CSS/Multiple.php index ca053250..0d1c8406 100644 --- a/library/HTMLPurifier/AttrDef/Multiple.php +++ b/library/HTMLPurifier/AttrDef/CSS/Multiple.php @@ -13,7 +13,7 @@ require_once 'HTMLPurifier/AttrDef.php'; * can only be used alone: it will never manifest as part of a multi * shorthand declaration. Thus, this class does not allow inherit. */ -class HTMLPurifier_AttrDef_Multiple extends HTMLPurifier_AttrDef +class HTMLPurifier_AttrDef_CSS_Multiple extends HTMLPurifier_AttrDef { /** @@ -30,7 +30,7 @@ class HTMLPurifier_AttrDef_Multiple extends HTMLPurifier_AttrDef * @param $single HTMLPurifier_AttrDef to multiply * @param $max Max number of values allowed (usually four) */ - function HTMLPurifier_AttrDef_Multiple($single, $max = 4) { + function HTMLPurifier_AttrDef_CSS_Multiple($single, $max = 4) { $this->single = $single; $this->max = $max; } diff --git a/library/HTMLPurifier/AttrDef/Number.php b/library/HTMLPurifier/AttrDef/CSS/Number.php similarity index 90% rename from library/HTMLPurifier/AttrDef/Number.php rename to library/HTMLPurifier/AttrDef/CSS/Number.php index f28f80fc..48f1335a 100644 --- a/library/HTMLPurifier/AttrDef/Number.php +++ b/library/HTMLPurifier/AttrDef/CSS/Number.php @@ -3,7 +3,7 @@ /** * Validates a number as defined by the CSS spec. */ -class HTMLPurifier_AttrDef_Number extends HTMLPurifier_AttrDef +class HTMLPurifier_AttrDef_CSS_Number extends HTMLPurifier_AttrDef { /** @@ -14,7 +14,7 @@ class HTMLPurifier_AttrDef_Number extends HTMLPurifier_AttrDef /** * @param $non_negative Bool indicating whether negatives are forbidden */ - function HTMLPurifier_AttrDef_Number($non_negative = false) { + function HTMLPurifier_AttrDef_CSS_Number($non_negative = false) { $this->non_negative = $non_negative; } diff --git a/library/HTMLPurifier/AttrDef/Percentage.php b/library/HTMLPurifier/AttrDef/CSS/Percentage.php similarity index 68% rename from library/HTMLPurifier/AttrDef/Percentage.php rename to library/HTMLPurifier/AttrDef/CSS/Percentage.php index fcab2868..cc96f15d 100644 --- a/library/HTMLPurifier/AttrDef/Percentage.php +++ b/library/HTMLPurifier/AttrDef/CSS/Percentage.php @@ -1,24 +1,24 @@ number_def = new HTMLPurifier_AttrDef_Number($non_negative); + function HTMLPurifier_AttrDef_CSS_Percentage($non_negative = false) { + $this->number_def = new HTMLPurifier_AttrDef_CSS_Number($non_negative); } function validate($string, $config, &$context) { diff --git a/library/HTMLPurifier/AttrDef/TextDecoration.php b/library/HTMLPurifier/AttrDef/CSS/TextDecoration.php similarity index 92% rename from library/HTMLPurifier/AttrDef/TextDecoration.php rename to library/HTMLPurifier/AttrDef/CSS/TextDecoration.php index 90d011e4..294dd830 100644 --- a/library/HTMLPurifier/AttrDef/TextDecoration.php +++ b/library/HTMLPurifier/AttrDef/CSS/TextDecoration.php @@ -7,7 +7,7 @@ require_once 'HTMLPurifier/AttrDef.php'; * @note This class could be generalized into a version that acts sort of * like Enum except you can compound the allowed values. */ -class HTMLPurifier_AttrDef_TextDecoration extends HTMLPurifier_AttrDef +class HTMLPurifier_AttrDef_CSS_TextDecoration extends HTMLPurifier_AttrDef { /** diff --git a/library/HTMLPurifier/AttrDef/CSSURI.php b/library/HTMLPurifier/AttrDef/CSS/URI.php similarity index 94% rename from library/HTMLPurifier/AttrDef/CSSURI.php rename to library/HTMLPurifier/AttrDef/CSS/URI.php index cb2fe7b9..b310907c 100644 --- a/library/HTMLPurifier/AttrDef/CSSURI.php +++ b/library/HTMLPurifier/AttrDef/CSS/URI.php @@ -11,10 +11,10 @@ require_once 'HTMLPurifier/AttrDef/URI.php'; * the separator, you cannot put a literal semicolon in * in the URI. Try percent encoding it, in that case. */ -class HTMLPurifier_AttrDef_CSSURI extends HTMLPurifier_AttrDef_URI +class HTMLPurifier_AttrDef_CSS_URI extends HTMLPurifier_AttrDef_URI { - function HTMLPurifier_AttrDef_CSSURI() { + function HTMLPurifier_AttrDef_CSS_URI() { $this->HTMLPurifier_AttrDef_URI(true); // always embedded } diff --git a/library/HTMLPurifier/AttrDef/ID.php b/library/HTMLPurifier/AttrDef/HTML/ID.php similarity index 98% rename from library/HTMLPurifier/AttrDef/ID.php rename to library/HTMLPurifier/AttrDef/HTML/ID.php index a4c54e4f..2a6d2c9a 100644 --- a/library/HTMLPurifier/AttrDef/ID.php +++ b/library/HTMLPurifier/AttrDef/HTML/ID.php @@ -52,7 +52,7 @@ HTMLPurifier_ConfigSchema::define( * blacklist. If you're hacking around, make sure you use load()! */ -class HTMLPurifier_AttrDef_ID extends HTMLPurifier_AttrDef +class HTMLPurifier_AttrDef_HTML_ID extends HTMLPurifier_AttrDef { // ref functionality disabled, since we also have to verify diff --git a/library/HTMLPurifier/AttrDef/Length.php b/library/HTMLPurifier/AttrDef/HTML/Length.php similarity index 77% rename from library/HTMLPurifier/AttrDef/Length.php rename to library/HTMLPurifier/AttrDef/HTML/Length.php index 0f27a6c4..ac83295a 100644 --- a/library/HTMLPurifier/AttrDef/Length.php +++ b/library/HTMLPurifier/AttrDef/HTML/Length.php @@ -1,18 +1,16 @@ host = new HTMLPurifier_AttrDef_Host(); + $this->host = new HTMLPurifier_AttrDef_URI_Host(); $this->PercentEncoder = new HTMLPurifier_PercentEncoder(); $this->embeds_resource = (bool) $embeds_resource; } diff --git a/library/HTMLPurifier/AttrDef/Email.php b/library/HTMLPurifier/AttrDef/URI/Email.php similarity index 75% rename from library/HTMLPurifier/AttrDef/Email.php rename to library/HTMLPurifier/AttrDef/URI/Email.php index 7a7ad6ab..80b8d367 100644 --- a/library/HTMLPurifier/AttrDef/Email.php +++ b/library/HTMLPurifier/AttrDef/URI/Email.php @@ -2,7 +2,7 @@ require_once 'HTMLPurifier/AttrDef.php'; -class HTMLPurifier_AttrDef_Email extends HTMLPurifier_AttrDef +class HTMLPurifier_AttrDef_URI_Email extends HTMLPurifier_AttrDef { /** diff --git a/library/HTMLPurifier/AttrDef/Email/SimpleCheck.php b/library/HTMLPurifier/AttrDef/URI/Email/SimpleCheck.php similarity index 79% rename from library/HTMLPurifier/AttrDef/Email/SimpleCheck.php rename to library/HTMLPurifier/AttrDef/URI/Email/SimpleCheck.php index 4b9fdf1a..e35b1b4b 100644 --- a/library/HTMLPurifier/AttrDef/Email/SimpleCheck.php +++ b/library/HTMLPurifier/AttrDef/URI/Email/SimpleCheck.php @@ -1,12 +1,12 @@ ipv4 = new HTMLPurifier_AttrDef_IPv4(); - $this->ipv6 = new HTMLPurifier_AttrDef_IPv6(); + function HTMLPurifier_AttrDef_URI_Host() { + $this->ipv4 = new HTMLPurifier_AttrDef_URI_IPv4(); + $this->ipv6 = new HTMLPurifier_AttrDef_URI_IPv6(); } function validate($string, $config, &$context) { diff --git a/library/HTMLPurifier/AttrDef/IPv4.php b/library/HTMLPurifier/AttrDef/URI/IPv4.php similarity index 84% rename from library/HTMLPurifier/AttrDef/IPv4.php rename to library/HTMLPurifier/AttrDef/URI/IPv4.php index a16305ad..0730bbc8 100644 --- a/library/HTMLPurifier/AttrDef/IPv4.php +++ b/library/HTMLPurifier/AttrDef/URI/IPv4.php @@ -6,7 +6,7 @@ require_once 'HTMLPurifier/AttrDef.php'; * Validates an IPv4 address * @author Feyd @ forums.devnetwork.net (public domain) */ -class HTMLPurifier_AttrDef_IPv4 extends HTMLPurifier_AttrDef +class HTMLPurifier_AttrDef_URI_IPv4 extends HTMLPurifier_AttrDef { /** @@ -15,7 +15,7 @@ class HTMLPurifier_AttrDef_IPv4 extends HTMLPurifier_AttrDef */ var $ip4; - function HTMLPurifier_AttrDef_IPv4() { + function HTMLPurifier_AttrDef_URI_IPv4() { $oct = '(?:25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9][0-9]|[0-9])'; // 0-255 $this->ip4 = "(?:{$oct}\\.{$oct}\\.{$oct}\\.{$oct})"; } diff --git a/library/HTMLPurifier/AttrDef/IPv6.php b/library/HTMLPurifier/AttrDef/URI/IPv6.php similarity index 95% rename from library/HTMLPurifier/AttrDef/IPv6.php rename to library/HTMLPurifier/AttrDef/URI/IPv6.php index 21b1ed8f..73f085e5 100644 --- a/library/HTMLPurifier/AttrDef/IPv6.php +++ b/library/HTMLPurifier/AttrDef/URI/IPv6.php @@ -1,6 +1,6 @@ info['NMTOKENS'] = new HTMLPurifier_AttrDef_Nmtokens(); - $this->info['CDATA'] = new HTMLPurifier_AttrDef_Text(); - $this->info['Text'] = new HTMLPurifier_AttrDef_Text(); - $this->info['ID'] = new HTMLPurifier_AttrDef_ID(); - $this->info['URI'] = new HTMLPurifier_AttrDef_URI(); - $this->info['Pixels'] = new HTMLPurifier_AttrDef_Pixels(); - $this->info['Length'] = new HTMLPurifier_AttrDef_Length(); - $this->info['MultiLength'] = new HTMLPurifier_AttrDef_MultiLength(); - // number is really a positive integer, according to XML one or - // more digits - $this->info['Number'] = new HTMLPurifier_AttrDef_Integer(false, false, true); + $this->info['CDATA'] = new HTMLPurifier_AttrDef_Text(); + $this->info['ID'] = new HTMLPurifier_AttrDef_HTML_ID(); + $this->info['Length'] = new HTMLPurifier_AttrDef_HTML_Length(); + $this->info['MultiLength'] = new HTMLPurifier_AttrDef_HTML_MultiLength(); + $this->info['NMTOKENS'] = new HTMLPurifier_AttrDef_HTML_Nmtokens(); + $this->info['Pixels'] = new HTMLPurifier_AttrDef_HTML_Pixels(); + $this->info['Text'] = new HTMLPurifier_AttrDef_Text(); + $this->info['URI'] = new HTMLPurifier_AttrDef_URI(); + + // number is really a positive integer (one or more digits) + $this->info['Number'] = new HTMLPurifier_AttrDef_Integer(false, false, true); } } diff --git a/library/HTMLPurifier/CSSDefinition.php b/library/HTMLPurifier/CSSDefinition.php index 0bbe8af5..55f0adc9 100644 --- a/library/HTMLPurifier/CSSDefinition.php +++ b/library/HTMLPurifier/CSSDefinition.php @@ -1,19 +1,19 @@ info['border-style'] = new HTMLPurifier_AttrDef_Multiple($border_style); + $this->info['border-style'] = new HTMLPurifier_AttrDef_CSS_Multiple($border_style); $this->info['clear'] = new HTMLPurifier_AttrDef_Enum( array('none', 'left', 'right', 'both'), false); @@ -54,10 +54,10 @@ class HTMLPurifier_CSSDefinition $this->info['font-variant'] = new HTMLPurifier_AttrDef_Enum( array('normal', 'small-caps'), false); - $uri_or_none = new HTMLPurifier_AttrDef_Composite( + $uri_or_none = new HTMLPurifier_AttrDef_CSS_Composite( array( new HTMLPurifier_AttrDef_Enum(array('none')), - new HTMLPurifier_AttrDef_CSSURI() + new HTMLPurifier_AttrDef_CSS_URI() ) ); @@ -68,11 +68,11 @@ class HTMLPurifier_CSSDefinition 'upper-roman', 'lower-alpha', 'upper-alpha', 'none'), false); $this->info['list-style-image'] = $uri_or_none; - $this->info['list-style'] = new HTMLPurifier_AttrDef_ListStyle($config); + $this->info['list-style'] = new HTMLPurifier_AttrDef_CSS_ListStyle($config); $this->info['text-transform'] = new HTMLPurifier_AttrDef_Enum( array('capitalize', 'uppercase', 'lowercase', 'none'), false); - $this->info['color'] = new HTMLPurifier_AttrDef_Color(); + $this->info['color'] = new HTMLPurifier_AttrDef_CSS_Color(); $this->info['background-image'] = $uri_or_none; $this->info['background-repeat'] = new HTMLPurifier_AttrDef_Enum( @@ -81,96 +81,96 @@ class HTMLPurifier_CSSDefinition $this->info['background-attachment'] = new HTMLPurifier_AttrDef_Enum( array('scroll', 'fixed') ); - $this->info['background-position'] = new HTMLPurifier_AttrDef_BackgroundPosition(); + $this->info['background-position'] = new HTMLPurifier_AttrDef_CSS_BackgroundPosition(); $border_color = $this->info['border-top-color'] = $this->info['border-bottom-color'] = $this->info['border-left-color'] = $this->info['border-right-color'] = - $this->info['background-color'] = new HTMLPurifier_AttrDef_Composite(array( + $this->info['background-color'] = new HTMLPurifier_AttrDef_CSS_Composite(array( new HTMLPurifier_AttrDef_Enum(array('transparent')), - new HTMLPurifier_AttrDef_Color() + new HTMLPurifier_AttrDef_CSS_Color() )); - $this->info['background'] = new HTMLPurifier_AttrDef_Background($config); + $this->info['background'] = new HTMLPurifier_AttrDef_CSS_Background($config); - $this->info['border-color'] = new HTMLPurifier_AttrDef_Multiple($border_color); + $this->info['border-color'] = new HTMLPurifier_AttrDef_CSS_Multiple($border_color); $border_width = $this->info['border-top-width'] = $this->info['border-bottom-width'] = $this->info['border-left-width'] = - $this->info['border-right-width'] = new HTMLPurifier_AttrDef_Composite(array( + $this->info['border-right-width'] = new HTMLPurifier_AttrDef_CSS_Composite(array( new HTMLPurifier_AttrDef_Enum(array('thin', 'medium', 'thick')), - new HTMLPurifier_AttrDef_CSSLength(true) //disallow negative + new HTMLPurifier_AttrDef_CSS_Length(true) //disallow negative )); - $this->info['border-width'] = new HTMLPurifier_AttrDef_Multiple($border_width); + $this->info['border-width'] = new HTMLPurifier_AttrDef_CSS_Multiple($border_width); - $this->info['letter-spacing'] = new HTMLPurifier_AttrDef_Composite(array( + $this->info['letter-spacing'] = new HTMLPurifier_AttrDef_CSS_Composite(array( new HTMLPurifier_AttrDef_Enum(array('normal')), - new HTMLPurifier_AttrDef_CSSLength() + new HTMLPurifier_AttrDef_CSS_Length() )); - $this->info['word-spacing'] = new HTMLPurifier_AttrDef_Composite(array( + $this->info['word-spacing'] = new HTMLPurifier_AttrDef_CSS_Composite(array( new HTMLPurifier_AttrDef_Enum(array('normal')), - new HTMLPurifier_AttrDef_CSSLength() + new HTMLPurifier_AttrDef_CSS_Length() )); - $this->info['font-size'] = new HTMLPurifier_AttrDef_Composite(array( + $this->info['font-size'] = new HTMLPurifier_AttrDef_CSS_Composite(array( new HTMLPurifier_AttrDef_Enum(array('xx-small', 'x-small', 'small', 'medium', 'large', 'x-large', 'xx-large', 'larger', 'smaller')), - new HTMLPurifier_AttrDef_Percentage(), - new HTMLPurifier_AttrDef_CSSLength() + new HTMLPurifier_AttrDef_CSS_Percentage(), + new HTMLPurifier_AttrDef_CSS_Length() )); - $this->info['line-height'] = new HTMLPurifier_AttrDef_Composite(array( + $this->info['line-height'] = new HTMLPurifier_AttrDef_CSS_Composite(array( new HTMLPurifier_AttrDef_Enum(array('normal')), - new HTMLPurifier_AttrDef_Number(true), // no negatives - new HTMLPurifier_AttrDef_CSSLength(true), - new HTMLPurifier_AttrDef_Percentage(true) + new HTMLPurifier_AttrDef_CSS_Number(true), // no negatives + new HTMLPurifier_AttrDef_CSS_Length(true), + new HTMLPurifier_AttrDef_CSS_Percentage(true) )); $margin = $this->info['margin-top'] = $this->info['margin-bottom'] = $this->info['margin-left'] = - $this->info['margin-right'] = new HTMLPurifier_AttrDef_Composite(array( - new HTMLPurifier_AttrDef_CSSLength(), - new HTMLPurifier_AttrDef_Percentage(), + $this->info['margin-right'] = new HTMLPurifier_AttrDef_CSS_Composite(array( + new HTMLPurifier_AttrDef_CSS_Length(), + new HTMLPurifier_AttrDef_CSS_Percentage(), new HTMLPurifier_AttrDef_Enum(array('auto')) )); - $this->info['margin'] = new HTMLPurifier_AttrDef_Multiple($margin); + $this->info['margin'] = new HTMLPurifier_AttrDef_CSS_Multiple($margin); // non-negative $padding = $this->info['padding-top'] = $this->info['padding-bottom'] = $this->info['padding-left'] = - $this->info['padding-right'] = new HTMLPurifier_AttrDef_Composite(array( - new HTMLPurifier_AttrDef_CSSLength(true), - new HTMLPurifier_AttrDef_Percentage(true) + $this->info['padding-right'] = new HTMLPurifier_AttrDef_CSS_Composite(array( + new HTMLPurifier_AttrDef_CSS_Length(true), + new HTMLPurifier_AttrDef_CSS_Percentage(true) )); - $this->info['padding'] = new HTMLPurifier_AttrDef_Multiple($padding); + $this->info['padding'] = new HTMLPurifier_AttrDef_CSS_Multiple($padding); - $this->info['text-indent'] = new HTMLPurifier_AttrDef_Composite(array( - new HTMLPurifier_AttrDef_CSSLength(), - new HTMLPurifier_AttrDef_Percentage() + $this->info['text-indent'] = new HTMLPurifier_AttrDef_CSS_Composite(array( + new HTMLPurifier_AttrDef_CSS_Length(), + new HTMLPurifier_AttrDef_CSS_Percentage() )); - $this->info['width'] = new HTMLPurifier_AttrDef_Composite(array( - new HTMLPurifier_AttrDef_CSSLength(true), - new HTMLPurifier_AttrDef_Percentage(true), + $this->info['width'] = new HTMLPurifier_AttrDef_CSS_Composite(array( + new HTMLPurifier_AttrDef_CSS_Length(true), + new HTMLPurifier_AttrDef_CSS_Percentage(true), new HTMLPurifier_AttrDef_Enum(array('auto')) )); - $this->info['text-decoration'] = new HTMLPurifier_AttrDef_TextDecoration(); + $this->info['text-decoration'] = new HTMLPurifier_AttrDef_CSS_TextDecoration(); - $this->info['font-family'] = new HTMLPurifier_AttrDef_FontFamily(); + $this->info['font-family'] = new HTMLPurifier_AttrDef_CSS_FontFamily(); // this could use specialized code $this->info['font-weight'] = new HTMLPurifier_AttrDef_Enum( @@ -179,14 +179,14 @@ class HTMLPurifier_CSSDefinition // MUST be called after other font properties, as it references // a CSSDefinition object - $this->info['font'] = new HTMLPurifier_AttrDef_Font($config); + $this->info['font'] = new HTMLPurifier_AttrDef_CSS_Font($config); // same here $this->info['border'] = $this->info['border-bottom'] = $this->info['border-top'] = $this->info['border-left'] = - $this->info['border-right'] = new HTMLPurifier_AttrDef_Border($config); + $this->info['border-right'] = new HTMLPurifier_AttrDef_CSS_Border($config); $this->info['border-collapse'] = new HTMLPurifier_AttrDef_Enum(array( 'collapse', 'seperate')); @@ -197,11 +197,11 @@ class HTMLPurifier_CSSDefinition $this->info['table-layout'] = new HTMLPurifier_AttrDef_Enum(array( 'auto', 'fixed')); - $this->info['vertical-align'] = new HTMLPurifier_AttrDef_Composite(array( + $this->info['vertical-align'] = new HTMLPurifier_AttrDef_CSS_Composite(array( new HTMLPurifier_AttrDef_Enum(array('baseline', 'sub', 'super', 'top', 'text-top', 'middle', 'bottom', 'text-bottom')), - new HTMLPurifier_AttrDef_CSSLength(), - new HTMLPurifier_AttrDef_Percentage() + new HTMLPurifier_AttrDef_CSS_Length(), + new HTMLPurifier_AttrDef_CSS_Percentage() )); } diff --git a/library/HTMLPurifier/HTMLDefinition.php b/library/HTMLPurifier/HTMLDefinition.php index 3e71dab7..45606db4 100644 --- a/library/HTMLPurifier/HTMLDefinition.php +++ b/library/HTMLPurifier/HTMLDefinition.php @@ -7,7 +7,7 @@ require_once 'HTMLPurifier/ContentSets.php'; require_once 'HTMLPurifier/ElementDef.php'; require_once 'HTMLPurifier/AttrDef.php'; -require_once 'HTMLPurifier/AttrDef/Enum.php'; // common +require_once 'HTMLPurifier/AttrDef/Enum.php'; // temporary: attribute transformations require_once 'HTMLPurifier/AttrTransform.php'; diff --git a/tests/HTMLPurifier/AttrDef/BackgroundPositionTest.php b/tests/HTMLPurifier/AttrDef/CSS/BackgroundPositionTest.php similarity index 90% rename from tests/HTMLPurifier/AttrDef/BackgroundPositionTest.php rename to tests/HTMLPurifier/AttrDef/CSS/BackgroundPositionTest.php index ce720841..911823f4 100644 --- a/tests/HTMLPurifier/AttrDef/BackgroundPositionTest.php +++ b/tests/HTMLPurifier/AttrDef/CSS/BackgroundPositionTest.php @@ -1,14 +1,14 @@ def = new HTMLPurifier_AttrDef_BackgroundPosition(); + $this->def = new HTMLPurifier_AttrDef_CSS_BackgroundPosition(); // explicitly cited in spec $this->assertDef('0% 0%'); diff --git a/tests/HTMLPurifier/AttrDef/BackgroundTest.php b/tests/HTMLPurifier/AttrDef/CSS/BackgroundTest.php similarity index 52% rename from tests/HTMLPurifier/AttrDef/BackgroundTest.php rename to tests/HTMLPurifier/AttrDef/CSS/BackgroundTest.php index 69b3c1ba..d4db8493 100644 --- a/tests/HTMLPurifier/AttrDef/BackgroundTest.php +++ b/tests/HTMLPurifier/AttrDef/CSS/BackgroundTest.php @@ -1,14 +1,15 @@ def = new HTMLPurifier_AttrDef_Background(HTMLPurifier_Config::createDefault()); + $config = HTMLPurifier_Config::createDefault(); + $this->def = new HTMLPurifier_AttrDef_CSS_Background($config); $valid = '#333 url(chess.png) repeat fixed 50% top'; $this->assertDef($valid); diff --git a/tests/HTMLPurifier/AttrDef/BorderTest.php b/tests/HTMLPurifier/AttrDef/CSS/BorderTest.php similarity index 50% rename from tests/HTMLPurifier/AttrDef/BorderTest.php rename to tests/HTMLPurifier/AttrDef/CSS/BorderTest.php index b18bfe70..521588db 100644 --- a/tests/HTMLPurifier/AttrDef/BorderTest.php +++ b/tests/HTMLPurifier/AttrDef/CSS/BorderTest.php @@ -1,14 +1,14 @@ def = new HTMLPurifier_AttrDef_Border(HTMLPurifier_Config::createDefault()); + $config = HTMLPurifier_Config::createDefault(); + $this->def = new HTMLPurifier_AttrDef_CSS_Border($config); $this->assertDef('thick solid red', 'thick solid #F00'); $this->assertDef('thick solid'); diff --git a/tests/HTMLPurifier/AttrDef/ColorTest.php b/tests/HTMLPurifier/AttrDef/CSS/ColorTest.php similarity index 83% rename from tests/HTMLPurifier/AttrDef/ColorTest.php rename to tests/HTMLPurifier/AttrDef/CSS/ColorTest.php index b44082c0..1c29ae68 100644 --- a/tests/HTMLPurifier/AttrDef/ColorTest.php +++ b/tests/HTMLPurifier/AttrDef/CSS/ColorTest.php @@ -1,14 +1,14 @@ def = new HTMLPurifier_AttrDef_Color(); + $this->def = new HTMLPurifier_AttrDef_CSS_Color(); $this->assertDef('#F00'); $this->assertDef('#808080'); diff --git a/tests/HTMLPurifier/AttrDef/CompositeTest.php b/tests/HTMLPurifier/AttrDef/CSS/CompositeTest.php similarity index 83% rename from tests/HTMLPurifier/AttrDef/CompositeTest.php rename to tests/HTMLPurifier/AttrDef/CSS/CompositeTest.php index 8ea7b5e8..3ec60e7d 100644 --- a/tests/HTMLPurifier/AttrDef/CompositeTest.php +++ b/tests/HTMLPurifier/AttrDef/CSS/CompositeTest.php @@ -1,20 +1,20 @@ defs =& $defs; } } -class HTMLPurifier_AttrDef_CompositeTest extends HTMLPurifier_AttrDefHarness +class HTMLPurifier_AttrDef_CSS_CompositeTest extends HTMLPurifier_AttrDefHarness { var $def1, $def2; @@ -32,7 +32,7 @@ class HTMLPurifier_AttrDef_CompositeTest extends HTMLPurifier_AttrDefHarness $def1 = new HTMLPurifier_AttrDefMock($this); $def2 = new HTMLPurifier_AttrDefMock($this); $defs = array(&$def1, &$def2); - $def = new HTMLPurifier_AttrDef_Composite_Testable($defs); + $def = new HTMLPurifier_AttrDef_CSS_Composite_Testable($defs); $input = 'FOOBAR'; $output = 'foobar'; $def1_params = array($input, $config, $context); @@ -51,7 +51,7 @@ class HTMLPurifier_AttrDef_CompositeTest extends HTMLPurifier_AttrDefHarness $def1 = new HTMLPurifier_AttrDefMock($this); $def2 = new HTMLPurifier_AttrDefMock($this); $defs = array(&$def1, &$def2); - $def = new HTMLPurifier_AttrDef_Composite_Testable($defs); + $def = new HTMLPurifier_AttrDef_CSS_Composite_Testable($defs); $input = 'BOOMA'; $output = 'booma'; $def_params = array($input, $config, $context); @@ -71,7 +71,7 @@ class HTMLPurifier_AttrDef_CompositeTest extends HTMLPurifier_AttrDefHarness $def1 = new HTMLPurifier_AttrDefMock($this); $def2 = new HTMLPurifier_AttrDefMock($this); $defs = array(&$def1, &$def2); - $def = new HTMLPurifier_AttrDef_Composite_Testable($defs); + $def = new HTMLPurifier_AttrDef_CSS_Composite_Testable($defs); $input = 'BOOMA'; $output = false; $def_params = array($input, $config, $context); diff --git a/tests/HTMLPurifier/AttrDef/FontFamilyTest.php b/tests/HTMLPurifier/AttrDef/CSS/FontFamilyTest.php similarity index 69% rename from tests/HTMLPurifier/AttrDef/FontFamilyTest.php rename to tests/HTMLPurifier/AttrDef/CSS/FontFamilyTest.php index 47c0e779..a802d45f 100644 --- a/tests/HTMLPurifier/AttrDef/FontFamilyTest.php +++ b/tests/HTMLPurifier/AttrDef/CSS/FontFamilyTest.php @@ -1,14 +1,14 @@ def = new HTMLPurifier_AttrDef_FontFamily(); + $this->def = new HTMLPurifier_AttrDef_CSS_FontFamily(); $this->assertDef('Gill, Helvetica, sans-serif'); $this->assertDef('\'Times New Roman\', serif'); diff --git a/tests/HTMLPurifier/AttrDef/FontTest.php b/tests/HTMLPurifier/AttrDef/CSS/FontTest.php similarity index 79% rename from tests/HTMLPurifier/AttrDef/FontTest.php rename to tests/HTMLPurifier/AttrDef/CSS/FontTest.php index 49b3652c..6bcb4fe2 100644 --- a/tests/HTMLPurifier/AttrDef/FontTest.php +++ b/tests/HTMLPurifier/AttrDef/CSS/FontTest.php @@ -1,14 +1,15 @@ def = new HTMLPurifier_AttrDef_Font(HTMLPurifier_Config::createDefault()); + $config = HTMLPurifier_Config::createDefault(); + $this->def = new HTMLPurifier_AttrDef_CSS_Font($config); // hodgepodge of usage cases from W3C spec, but " -> ' $this->assertDef('12px/14px sans-serif'); diff --git a/tests/HTMLPurifier/AttrDef/CSSLengthTest.php b/tests/HTMLPurifier/AttrDef/CSS/LengthTest.php similarity index 75% rename from tests/HTMLPurifier/AttrDef/CSSLengthTest.php rename to tests/HTMLPurifier/AttrDef/CSS/LengthTest.php index fabea20f..56129af2 100644 --- a/tests/HTMLPurifier/AttrDef/CSSLengthTest.php +++ b/tests/HTMLPurifier/AttrDef/CSS/LengthTest.php @@ -1,14 +1,14 @@ def = new HTMLPurifier_AttrDef_CSSLength(); + $this->def = new HTMLPurifier_AttrDef_CSS_Length(); $this->assertDef('0'); $this->assertDef('0px'); @@ -31,7 +31,7 @@ class HTMLPurifier_AttrDef_CSSLengthTest extends HTMLPurifier_AttrDefHarness function testNonNegative() { - $this->def = new HTMLPurifier_AttrDef_CSSLength(true); + $this->def = new HTMLPurifier_AttrDef_CSS_Length(true); $this->assertDef('3cm'); $this->assertDef('-3mm', false); diff --git a/tests/HTMLPurifier/AttrDef/ListStyleTest.php b/tests/HTMLPurifier/AttrDef/CSS/ListStyleTest.php similarity index 77% rename from tests/HTMLPurifier/AttrDef/ListStyleTest.php rename to tests/HTMLPurifier/AttrDef/CSS/ListStyleTest.php index 95ef9444..6863c489 100644 --- a/tests/HTMLPurifier/AttrDef/ListStyleTest.php +++ b/tests/HTMLPurifier/AttrDef/CSS/ListStyleTest.php @@ -1,14 +1,15 @@ def = new HTMLPurifier_AttrDef_ListStyle(HTMLPurifier_Config::createDefault()); + $config = HTMLPurifier_Config::createDefault(); + $this->def = new HTMLPurifier_AttrDef_CSS_ListStyle($config); $this->assertDef('lower-alpha'); $this->assertDef('upper-roman inside'); diff --git a/tests/HTMLPurifier/AttrDef/MultipleTest.php b/tests/HTMLPurifier/AttrDef/CSS/MultipleTest.php similarity index 77% rename from tests/HTMLPurifier/AttrDef/MultipleTest.php rename to tests/HTMLPurifier/AttrDef/CSS/MultipleTest.php index 8c102b39..075c56ad 100644 --- a/tests/HTMLPurifier/AttrDef/MultipleTest.php +++ b/tests/HTMLPurifier/AttrDef/CSS/MultipleTest.php @@ -1,16 +1,16 @@ def = new HTMLPurifier_AttrDef_Multiple( + $this->def = new HTMLPurifier_AttrDef_CSS_Multiple( new HTMLPurifier_AttrDef_Integer() ); diff --git a/tests/HTMLPurifier/AttrDef/NumberTest.php b/tests/HTMLPurifier/AttrDef/CSS/NumberTest.php similarity index 73% rename from tests/HTMLPurifier/AttrDef/NumberTest.php rename to tests/HTMLPurifier/AttrDef/CSS/NumberTest.php index 4ddea5e6..f8f714f6 100644 --- a/tests/HTMLPurifier/AttrDef/NumberTest.php +++ b/tests/HTMLPurifier/AttrDef/CSS/NumberTest.php @@ -1,14 +1,14 @@ def = new HTMLPurifier_AttrDef_Number(); + $this->def = new HTMLPurifier_AttrDef_CSS_Number(); $this->assertDef('0'); $this->assertDef('34'); @@ -29,7 +29,7 @@ class HTMLPurifier_AttrDef_NumberTest extends HTMLPurifier_AttrDefHarness function testNonNegative() { - $this->def = new HTMLPurifier_AttrDef_Number(true); + $this->def = new HTMLPurifier_AttrDef_CSS_Number(true); $this->assertDef('23'); $this->assertDef('-12', false); diff --git a/tests/HTMLPurifier/AttrDef/PercentageTest.php b/tests/HTMLPurifier/AttrDef/CSS/PercentageTest.php similarity index 66% rename from tests/HTMLPurifier/AttrDef/PercentageTest.php rename to tests/HTMLPurifier/AttrDef/CSS/PercentageTest.php index 6694296c..2aa0d401 100644 --- a/tests/HTMLPurifier/AttrDef/PercentageTest.php +++ b/tests/HTMLPurifier/AttrDef/CSS/PercentageTest.php @@ -1,14 +1,14 @@ def = new HTMLPurifier_AttrDef_Percentage(); + $this->def = new HTMLPurifier_AttrDef_CSS_Percentage(); $this->assertDef('10%'); $this->assertDef('1.607%'); diff --git a/tests/HTMLPurifier/AttrDef/TextDecorationTest.php b/tests/HTMLPurifier/AttrDef/CSS/TextDecorationTest.php similarity index 72% rename from tests/HTMLPurifier/AttrDef/TextDecorationTest.php rename to tests/HTMLPurifier/AttrDef/CSS/TextDecorationTest.php index f633177f..e5f3e0c7 100644 --- a/tests/HTMLPurifier/AttrDef/TextDecorationTest.php +++ b/tests/HTMLPurifier/AttrDef/CSS/TextDecorationTest.php @@ -1,14 +1,14 @@ def = new HTMLPurifier_AttrDef_TextDecoration(); + $this->def = new HTMLPurifier_AttrDef_CSS_TextDecoration(); $this->assertDef('underline'); $this->assertDef('overline'); diff --git a/tests/HTMLPurifier/AttrDef/CSSURITest.php b/tests/HTMLPurifier/AttrDef/CSS/URITest.php similarity index 83% rename from tests/HTMLPurifier/AttrDef/CSSURITest.php rename to tests/HTMLPurifier/AttrDef/CSS/URITest.php index 1fe1a3dc..2a238d22 100644 --- a/tests/HTMLPurifier/AttrDef/CSSURITest.php +++ b/tests/HTMLPurifier/AttrDef/CSS/URITest.php @@ -1,14 +1,14 @@ def = new HTMLPurifier_AttrDef_CSSURI(); + $this->def = new HTMLPurifier_AttrDef_CSS_URI(); $this->assertDef('', false); diff --git a/tests/HTMLPurifier/AttrDef/Email/SimpleCheckTest.php b/tests/HTMLPurifier/AttrDef/Email/SimpleCheckTest.php deleted file mode 100644 index 70a77f72..00000000 --- a/tests/HTMLPurifier/AttrDef/Email/SimpleCheckTest.php +++ /dev/null @@ -1,16 +0,0 @@ -def = new HTMLPurifier_AttrDef_Email_SimpleCheck(); - } - -} - -?> \ No newline at end of file diff --git a/tests/HTMLPurifier/AttrDef/IDTest.php b/tests/HTMLPurifier/AttrDef/HTML/IDTest.php similarity index 88% rename from tests/HTMLPurifier/AttrDef/IDTest.php rename to tests/HTMLPurifier/AttrDef/HTML/IDTest.php index 42be7e13..a604ca0c 100644 --- a/tests/HTMLPurifier/AttrDef/IDTest.php +++ b/tests/HTMLPurifier/AttrDef/HTML/IDTest.php @@ -1,10 +1,10 @@ context->register('IDAccumulator', $id_accumulator); $this->config->set('Attr', 'EnableID', true); - $this->def = new HTMLPurifier_AttrDef_ID(); + $this->def = new HTMLPurifier_AttrDef_HTML_ID(); } @@ -78,18 +78,18 @@ class HTMLPurifier_AttrDef_IDTest extends HTMLPurifier_AttrDefHarness // reference functionality is disabled for now function disabled_testIDReference() { - $this->def = new HTMLPurifier_AttrDef_ID(true); + $this->def = new HTMLPurifier_AttrDef_HTML_ID(true); $this->assertDef('good_id'); $this->assertDef('good_id'); // duplicates okay $this->assertDef('', false); - $this->def = new HTMLPurifier_AttrDef_ID(); + $this->def = new HTMLPurifier_AttrDef_HTML_ID(); $this->assertDef('good_id'); $this->assertDef('good_id', false); // duplicate now not okay - $this->def = new HTMLPurifier_AttrDef_ID(true); + $this->def = new HTMLPurifier_AttrDef_HTML_ID(true); $this->assertDef('good_id'); // reference still okay diff --git a/tests/HTMLPurifier/AttrDef/LengthTest.php b/tests/HTMLPurifier/AttrDef/HTML/LengthTest.php similarity index 67% rename from tests/HTMLPurifier/AttrDef/LengthTest.php rename to tests/HTMLPurifier/AttrDef/HTML/LengthTest.php index f67c70b7..e5b89f22 100644 --- a/tests/HTMLPurifier/AttrDef/LengthTest.php +++ b/tests/HTMLPurifier/AttrDef/HTML/LengthTest.php @@ -1,13 +1,13 @@ def = new HTMLPurifier_AttrDef_Length(); + $this->def = new HTMLPurifier_AttrDef_HTML_Length(); } function test() { diff --git a/tests/HTMLPurifier/AttrDef/MultiLengthTest.php b/tests/HTMLPurifier/AttrDef/HTML/MultiLengthTest.php similarity index 56% rename from tests/HTMLPurifier/AttrDef/MultiLengthTest.php rename to tests/HTMLPurifier/AttrDef/HTML/MultiLengthTest.php index 6d9acd36..eaa34952 100644 --- a/tests/HTMLPurifier/AttrDef/MultiLengthTest.php +++ b/tests/HTMLPurifier/AttrDef/HTML/MultiLengthTest.php @@ -1,13 +1,13 @@ def = new HTMLPurifier_AttrDef_MultiLength(); + $this->def = new HTMLPurifier_AttrDef_HTML_MultiLength(); } function test() { @@ -16,7 +16,7 @@ class HTMLPurifier_AttrDef_MultiLengthTest extends HTMLPurifier_AttrDef_LengthTe parent::test(); $this->assertDef('*'); - $this->assertDef('1*'); + $this->assertDef('1*', '*'); $this->assertDef('56*'); $this->assertDef('**', false); // plain old bad diff --git a/tests/HTMLPurifier/AttrDef/NmtokensTest.php b/tests/HTMLPurifier/AttrDef/HTML/NmtokensTest.php similarity index 75% rename from tests/HTMLPurifier/AttrDef/NmtokensTest.php rename to tests/HTMLPurifier/AttrDef/HTML/NmtokensTest.php index 8b38a491..00b55eec 100644 --- a/tests/HTMLPurifier/AttrDef/NmtokensTest.php +++ b/tests/HTMLPurifier/AttrDef/HTML/NmtokensTest.php @@ -1,15 +1,14 @@ def = new HTMLPurifier_AttrDef_Nmtokens(); + $this->def = new HTMLPurifier_AttrDef_HTML_Nmtokens(); $this->assertDef('valid'); $this->assertDef('a0-_'); diff --git a/tests/HTMLPurifier/AttrDef/PixelsTest.php b/tests/HTMLPurifier/AttrDef/HTML/PixelsTest.php similarity index 79% rename from tests/HTMLPurifier/AttrDef/PixelsTest.php rename to tests/HTMLPurifier/AttrDef/HTML/PixelsTest.php index cab43e86..414fa3ad 100644 --- a/tests/HTMLPurifier/AttrDef/PixelsTest.php +++ b/tests/HTMLPurifier/AttrDef/HTML/PixelsTest.php @@ -1,13 +1,13 @@ def = new HTMLPurifier_AttrDef_Pixels(); + $this->def = new HTMLPurifier_AttrDef_HTML_Pixels(); } function test() { diff --git a/tests/HTMLPurifier/AttrDef/URI/Email/SimpleCheckTest.php b/tests/HTMLPurifier/AttrDef/URI/Email/SimpleCheckTest.php new file mode 100644 index 00000000..edbde119 --- /dev/null +++ b/tests/HTMLPurifier/AttrDef/URI/Email/SimpleCheckTest.php @@ -0,0 +1,16 @@ +def = new HTMLPurifier_AttrDef_URI_Email_SimpleCheck(); + } + +} + +?> \ No newline at end of file diff --git a/tests/HTMLPurifier/AttrDef/EmailHarness.php b/tests/HTMLPurifier/AttrDef/URI/EmailHarness.php similarity index 87% rename from tests/HTMLPurifier/AttrDef/EmailHarness.php rename to tests/HTMLPurifier/AttrDef/URI/EmailHarness.php index 28bd06f1..b0398424 100644 --- a/tests/HTMLPurifier/AttrDef/EmailHarness.php +++ b/tests/HTMLPurifier/AttrDef/URI/EmailHarness.php @@ -1,9 +1,9 @@ def = new HTMLPurifier_AttrDef_Host(); + $this->def = new HTMLPurifier_AttrDef_URI_Host(); $this->assertDef('[2001:DB8:0:0:8:800:200C:417A]'); // IPv6 $this->assertDef('124.15.6.89'); // IPv4 diff --git a/tests/HTMLPurifier/AttrDef/IPv4Test.php b/tests/HTMLPurifier/AttrDef/URI/IPv4Test.php similarity index 78% rename from tests/HTMLPurifier/AttrDef/IPv4Test.php rename to tests/HTMLPurifier/AttrDef/URI/IPv4Test.php index 59f560d9..aa05159c 100644 --- a/tests/HTMLPurifier/AttrDef/IPv4Test.php +++ b/tests/HTMLPurifier/AttrDef/URI/IPv4Test.php @@ -1,17 +1,17 @@ def = new HTMLPurifier_AttrDef_IPv4(); + $this->def = new HTMLPurifier_AttrDef_URI_IPv4(); $this->assertDef('127.0.0.1'); // standard IPv4, loopback, non-routable $this->assertDef('0.0.0.0'); // standard IPv4, unspecified, non-routable diff --git a/tests/HTMLPurifier/AttrDef/IPv6Test.php b/tests/HTMLPurifier/AttrDef/URI/IPv6Test.php similarity index 91% rename from tests/HTMLPurifier/AttrDef/IPv6Test.php rename to tests/HTMLPurifier/AttrDef/URI/IPv6Test.php index 7ad3613f..8a6511b0 100644 --- a/tests/HTMLPurifier/AttrDef/IPv6Test.php +++ b/tests/HTMLPurifier/AttrDef/URI/IPv6Test.php @@ -1,17 +1,17 @@ def = new HTMLPurifier_AttrDef_IPv6(); + $this->def = new HTMLPurifier_AttrDef_URI_IPv6(); $this->assertDef('2001:DB8:0:0:8:800:200C:417A'); // unicast, full $this->assertDef('FF01:0:0:0:0:0:0:101'); // multicast, full diff --git a/tests/test_files.php b/tests/test_files.php index 499022fa..055962e0 100644 --- a/tests/test_files.php +++ b/tests/test_files.php @@ -2,70 +2,71 @@ if (!defined('HTMLPurifierTest')) exit; -// define callable test files -$test_files[] = 'ConfigTest.php'; -$test_files[] = 'ConfigSchemaTest.php'; -$test_files[] = 'LexerTest.php'; -$test_files[] = 'Lexer/DirectLexTest.php'; -$test_files[] = 'TokenTest.php'; -$test_files[] = 'ChildDef/RequiredTest.php'; -$test_files[] = 'ChildDef/OptionalTest.php'; -$test_files[] = 'ChildDef/ChameleonTest.php'; -$test_files[] = 'ChildDef/CustomTest.php'; -$test_files[] = 'ChildDef/TableTest.php'; -$test_files[] = 'ChildDef/StrictBlockquoteTest.php'; -$test_files[] = 'GeneratorTest.php'; -$test_files[] = 'EntityLookupTest.php'; -$test_files[] = 'Strategy/RemoveForeignElementsTest.php'; -$test_files[] = 'Strategy/MakeWellFormedTest.php'; -$test_files[] = 'Strategy/FixNestingTest.php'; -$test_files[] = 'Strategy/CompositeTest.php'; -$test_files[] = 'Strategy/CoreTest.php'; -$test_files[] = 'Strategy/ValidateAttributesTest.php'; -$test_files[] = 'AttrDefTest.php'; -$test_files[] = 'AttrDef/EnumTest.php'; -$test_files[] = 'AttrDef/IDTest.php'; -$test_files[] = 'AttrDef/NmtokensTest.php'; -$test_files[] = 'AttrDef/TextTest.php'; -$test_files[] = 'AttrDef/LangTest.php'; -$test_files[] = 'AttrDef/PixelsTest.php'; -$test_files[] = 'AttrDef/LengthTest.php'; -$test_files[] = 'AttrDef/URITest.php'; +// define callable test files (sorted alphabetically) +$test_files[] = 'AttrDef/CSS/BackgroundPositionTest.php'; +$test_files[] = 'AttrDef/CSS/BackgroundTest.php'; +$test_files[] = 'AttrDef/CSS/BorderTest.php'; +$test_files[] = 'AttrDef/CSS/ColorTest.php'; +$test_files[] = 'AttrDef/CSS/CompositeTest.php'; +$test_files[] = 'AttrDef/CSS/FontFamilyTest.php'; +$test_files[] = 'AttrDef/CSS/FontTest.php'; +$test_files[] = 'AttrDef/CSS/LengthTest.php'; +$test_files[] = 'AttrDef/CSS/ListStyleTest.php'; +$test_files[] = 'AttrDef/CSS/MultipleTest.php'; +$test_files[] = 'AttrDef/CSS/NumberTest.php'; +$test_files[] = 'AttrDef/CSS/PercentageTest.php'; +$test_files[] = 'AttrDef/CSS/TextDecorationTest.php'; +$test_files[] = 'AttrDef/CSS/URITest.php'; $test_files[] = 'AttrDef/CSSTest.php'; -$test_files[] = 'AttrDef/CompositeTest.php'; -$test_files[] = 'AttrDef/ColorTest.php'; +$test_files[] = 'AttrDef/EnumTest.php'; +$test_files[] = 'AttrDef/HTML/IDTest.php'; +$test_files[] = 'AttrDef/HTML/LengthTest.php'; +$test_files[] = 'AttrDef/HTML/MultiLengthTest.php'; +$test_files[] = 'AttrDef/HTML/NmtokensTest.php'; +$test_files[] = 'AttrDef/HTML/PixelsTest.php'; $test_files[] = 'AttrDef/IntegerTest.php'; -$test_files[] = 'AttrDef/NumberTest.php'; -$test_files[] = 'AttrDef/CSSLengthTest.php'; -$test_files[] = 'AttrDef/PercentageTest.php'; -$test_files[] = 'AttrDef/MultipleTest.php'; -$test_files[] = 'AttrDef/TextDecorationTest.php'; -$test_files[] = 'AttrDef/FontFamilyTest.php'; -$test_files[] = 'AttrDef/HostTest.php'; -$test_files[] = 'AttrDef/IPv4Test.php'; -$test_files[] = 'AttrDef/IPv6Test.php'; -$test_files[] = 'AttrDef/FontTest.php'; -$test_files[] = 'AttrDef/BorderTest.php'; -$test_files[] = 'AttrDef/ListStyleTest.php'; -$test_files[] = 'AttrDef/Email/SimpleCheckTest.php'; -$test_files[] = 'AttrDef/CSSURITest.php'; -$test_files[] = 'AttrDef/BackgroundPositionTest.php'; -$test_files[] = 'AttrDef/BackgroundTest.php'; -$test_files[] = 'IDAccumulatorTest.php'; -$test_files[] = 'TagTransformTest.php'; -$test_files[] = 'AttrTransform/LangTest.php'; -$test_files[] = 'AttrTransform/TextAlignTest.php'; +$test_files[] = 'AttrDef/LangTest.php'; +$test_files[] = 'AttrDef/TextTest.php'; +$test_files[] = 'AttrDef/URI/Email/SimpleCheckTest.php'; +$test_files[] = 'AttrDef/URI/HostTest.php'; +$test_files[] = 'AttrDef/URI/IPv4Test.php'; +$test_files[] = 'AttrDef/URI/IPv6Test.php'; +$test_files[] = 'AttrDef/URITest.php'; +$test_files[] = 'AttrDefTest.php'; $test_files[] = 'AttrTransform/BdoDirTest.php'; $test_files[] = 'AttrTransform/ImgRequiredTest.php'; -$test_files[] = 'URISchemeRegistryTest.php'; -$test_files[] = 'URISchemeTest.php'; -$test_files[] = 'EncoderTest.php'; -$test_files[] = 'EntityParserTest.php'; -$test_files[] = 'Test.php'; +$test_files[] = 'AttrTransform/LangTest.php'; +$test_files[] = 'AttrTransform/TextAlignTest.php'; +$test_files[] = 'ChildDef/ChameleonTest.php'; +$test_files[] = 'ChildDef/CustomTest.php'; +$test_files[] = 'ChildDef/OptionalTest.php'; +$test_files[] = 'ChildDef/RequiredTest.php'; +$test_files[] = 'ChildDef/StrictBlockquoteTest.php'; +$test_files[] = 'ChildDef/TableTest.php'; +$test_files[] = 'ConfigSchemaTest.php'; +$test_files[] = 'ConfigTest.php'; $test_files[] = 'ContextTest.php'; -$test_files[] = 'PercentEncoderTest.php'; +$test_files[] = 'EncoderTest.php'; +$test_files[] = 'EntityLookupTest.php'; +$test_files[] = 'EntityParserTest.php'; +$test_files[] = 'GeneratorTest.php'; +$test_files[] = 'IDAccumulatorTest.php'; $test_files[] = 'LanguageFactoryTest.php'; $test_files[] = 'LanguageTest.php'; +$test_files[] = 'Lexer/DirectLexTest.php'; +$test_files[] = 'LexerTest.php'; +$test_files[] = 'PercentEncoderTest.php'; +$test_files[] = 'Strategy/CompositeTest.php'; +$test_files[] = 'Strategy/CoreTest.php'; +$test_files[] = 'Strategy/FixNestingTest.php'; +$test_files[] = 'Strategy/MakeWellFormedTest.php'; +$test_files[] = 'Strategy/RemoveForeignElementsTest.php'; +$test_files[] = 'Strategy/ValidateAttributesTest.php'; +$test_files[] = 'TagTransformTest.php'; +$test_files[] = 'Test.php'; +$test_files[] = 'TokenTest.php'; +$test_files[] = 'URISchemeRegistryTest.php'; +$test_files[] = 'URISchemeTest.php'; if (version_compare(PHP_VERSION, '5', '>=')) { $test_files[] = 'TokenFactoryTest.php';