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

Convert all to new configuration get/set format.

Signed-off-by: Edward Z. Yang <edwardzyang@thewritingpot.com>
This commit is contained in:
Edward Z. Yang 2009-02-19 19:17:49 -05:00
parent b107eec452
commit 86ca784da3
106 changed files with 504 additions and 815 deletions

View File

@ -1,402 +1,2 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<usage> <usage/>
<directive id="Core.CollectErrors">
<file name="HTMLPurifier.php">
<line>131</line>
</file>
<file name="HTMLPurifier/Lexer.php">
<line>81</line>
</file>
<file name="HTMLPurifier/Lexer/DirectLex.php">
<line>53</line>
<line>73</line>
<line>348</line>
</file>
<file name="HTMLPurifier/Strategy/RemoveForeignElements.php">
<line>47</line>
</file>
</directive>
<directive id="CSS.MaxImgLength">
<file name="HTMLPurifier/CSSDefinition.php">
<line>157</line>
</file>
</directive>
<directive id="CSS.Proprietary">
<file name="HTMLPurifier/CSSDefinition.php">
<line>214</line>
</file>
</directive>
<directive id="CSS.AllowTricky">
<file name="HTMLPurifier/CSSDefinition.php">
<line>218</line>
</file>
</directive>
<directive id="CSS.AllowImportant">
<file name="HTMLPurifier/CSSDefinition.php">
<line>222</line>
</file>
</directive>
<directive id="CSS.AllowedProperties">
<file name="HTMLPurifier/CSSDefinition.php">
<line>275</line>
</file>
</directive>
<directive id="Cache.DefinitionImpl">
<file name="HTMLPurifier/DefinitionCacheFactory.php">
<line>49</line>
</file>
</directive>
<directive id="HTML.Doctype">
<file name="HTMLPurifier/DoctypeRegistry.php">
<line>83</line>
</file>
</directive>
<directive id="HTML.CustomDoctype">
<file name="HTMLPurifier/DoctypeRegistry.php">
<line>85</line>
</file>
</directive>
<directive id="HTML.XHTML">
<file name="HTMLPurifier/DoctypeRegistry.php">
<line>88</line>
</file>
</directive>
<directive id="HTML.Strict">
<file name="HTMLPurifier/DoctypeRegistry.php">
<line>93</line>
</file>
</directive>
<directive id="Core.Encoding">
<file name="HTMLPurifier/Encoder.php">
<line>267</line>
<line>300</line>
</file>
</directive>
<directive id="Test.ForceNoIconv">
<file name="HTMLPurifier/Encoder.php">
<line>272</line>
<line>308</line>
</file>
</directive>
<directive id="Core.EscapeNonASCIICharacters">
<file name="HTMLPurifier/Encoder.php">
<line>304</line>
</file>
</directive>
<directive id="Output.CommentScriptContents">
<file name="HTMLPurifier/Generator.php">
<line>45</line>
</file>
</directive>
<directive id="Output.SortAttr">
<file name="HTMLPurifier/Generator.php">
<line>46</line>
</file>
</directive>
<directive id="Output.TidyFormat">
<file name="HTMLPurifier/Generator.php">
<line>75</line>
</file>
</directive>
<directive id="Output.Newline">
<file name="HTMLPurifier/Generator.php">
<line>89</line>
</file>
</directive>
<directive id="HTML.BlockWrapper">
<file name="HTMLPurifier/HTMLDefinition.php">
<line>222</line>
</file>
</directive>
<directive id="HTML.Parent">
<file name="HTMLPurifier/HTMLDefinition.php">
<line>230</line>
</file>
</directive>
<directive id="HTML.AllowedElements">
<file name="HTMLPurifier/HTMLDefinition.php">
<line>247</line>
</file>
</directive>
<directive id="HTML.AllowedAttributes">
<file name="HTMLPurifier/HTMLDefinition.php">
<line>248</line>
</file>
</directive>
<directive id="HTML.Allowed">
<file name="HTMLPurifier/HTMLDefinition.php">
<line>251</line>
</file>
</directive>
<directive id="HTML.ForbiddenElements">
<file name="HTMLPurifier/HTMLDefinition.php">
<line>337</line>
</file>
</directive>
<directive id="HTML.ForbiddenAttributes">
<file name="HTMLPurifier/HTMLDefinition.php">
<line>338</line>
</file>
</directive>
<directive id="HTML.Trusted">
<file name="HTMLPurifier/HTMLModuleManager.php">
<line>202</line>
</file>
<file name="HTMLPurifier/Lexer.php">
<line>258</line>
</file>
<file name="HTMLPurifier/HTMLModule/Image.php">
<line>27</line>
</file>
<file name="HTMLPurifier/Lexer/DirectLex.php">
<line>36</line>
</file>
<file name="HTMLPurifier/Strategy/RemoveForeignElements.php">
<line>23</line>
</file>
</directive>
<directive id="HTML.AllowedModules">
<file name="HTMLPurifier/HTMLModuleManager.php">
<line>209</line>
</file>
</directive>
<directive id="HTML.CoreModules">
<file name="HTMLPurifier/HTMLModuleManager.php">
<line>210</line>
</file>
</directive>
<directive id="HTML.Proprietary">
<file name="HTMLPurifier/HTMLModuleManager.php">
<line>221</line>
</file>
</directive>
<directive id="HTML.SafeObject">
<file name="HTMLPurifier/HTMLModuleManager.php">
<line>226</line>
</file>
</directive>
<directive id="HTML.SafeEmbed">
<file name="HTMLPurifier/HTMLModuleManager.php">
<line>229</line>
</file>
</directive>
<directive id="Attr.IDBlacklist">
<file name="HTMLPurifier/IDAccumulator.php">
<line>26</line>
</file>
</directive>
<directive id="Core.Language">
<file name="HTMLPurifier/LanguageFactory.php">
<line>88</line>
</file>
</directive>
<directive id="Core.LexerImpl">
<file name="HTMLPurifier/Lexer.php">
<line>76</line>
</file>
</directive>
<directive id="Core.MaintainLineNumbers">
<file name="HTMLPurifier/Lexer.php">
<line>80</line>
</file>
<file name="HTMLPurifier/Lexer/DirectLex.php">
<line>48</line>
</file>
</directive>
<directive id="Core.ConvertDocumentToFragment">
<file name="HTMLPurifier/Lexer.php">
<line>267</line>
</file>
</directive>
<directive id="URI.Host">
<file name="HTMLPurifier/URIDefinition.php">
<line>64</line>
</file>
</directive>
<directive id="URI.Base">
<file name="HTMLPurifier/URIDefinition.php">
<line>65</line>
</file>
</directive>
<directive id="URI.DefaultScheme">
<file name="HTMLPurifier/URIDefinition.php">
<line>72</line>
</file>
</directive>
<directive id="URI.AllowedSchemes">
<file name="HTMLPurifier/URISchemeRegistry.php">
<line>42</line>
</file>
</directive>
<directive id="URI.OverrideAllowedSchemes">
<file name="HTMLPurifier/URISchemeRegistry.php">
<line>43</line>
</file>
</directive>
<directive id="URI.Disable">
<file name="HTMLPurifier/AttrDef/URI.php">
<line>28</line>
</file>
</directive>
<directive id="Core.ColorKeywords">
<file name="HTMLPurifier/AttrDef/CSS/Color.php">
<line>12</line>
</file>
<file name="HTMLPurifier/AttrDef/HTML/Color.php">
<line>12</line>
</file>
</directive>
<directive id="Attr.AllowedFrameTargets">
<file name="HTMLPurifier/AttrDef/HTML/FrameTarget.php">
<line>15</line>
</file>
</directive>
<directive id="Attr.EnableID">
<file name="HTMLPurifier/AttrDef/HTML/ID.php">
<line>20</line>
</file>
</directive>
<directive id="Attr.IDPrefix">
<file name="HTMLPurifier/AttrDef/HTML/ID.php">
<line>26</line>
</file>
</directive>
<directive id="Attr.IDPrefixLocal">
<file name="HTMLPurifier/AttrDef/HTML/ID.php">
<line>28</line>
<line>31</line>
</file>
</directive>
<directive id="Attr.IDBlacklistRegexp">
<file name="HTMLPurifier/AttrDef/HTML/ID.php">
<line>54</line>
</file>
</directive>
<directive id="Attr.DefaultTextDir">
<file name="HTMLPurifier/AttrTransform/BdoDir.php">
<line>13</line>
</file>
</directive>
<directive id="Core.RemoveInvalidImg">
<file name="HTMLPurifier/AttrTransform/ImgRequired.php">
<line>18</line>
</file>
<file name="HTMLPurifier/Strategy/RemoveForeignElements.php">
<line>20</line>
</file>
</directive>
<directive id="Attr.DefaultInvalidImage">
<file name="HTMLPurifier/AttrTransform/ImgRequired.php">
<line>19</line>
</file>
</directive>
<directive id="Attr.DefaultImageAlt">
<file name="HTMLPurifier/AttrTransform/ImgRequired.php">
<line>25</line>
</file>
</directive>
<directive id="Attr.DefaultInvalidImageAlt">
<file name="HTMLPurifier/AttrTransform/ImgRequired.php">
<line>32</line>
</file>
</directive>
<directive id="Core.EscapeInvalidChildren">
<file name="HTMLPurifier/ChildDef/Required.php">
<line>62</line>
</file>
</directive>
<directive id="Cache.SerializerPath">
<file name="HTMLPurifier/DefinitionCache/Serializer.php">
<line>91</line>
</file>
</directive>
<directive id="FilterParam.ExtractStyleBlocksTidyImpl">
<file name="HTMLPurifier/Filter/ExtractStyleBlocks.php">
<line>41</line>
</file>
</directive>
<directive id="FilterParam.ExtractStyleBlocksScope">
<file name="HTMLPurifier/Filter/ExtractStyleBlocks.php">
<line>65</line>
</file>
</directive>
<directive id="FilterParam.ExtractStyleBlocksEscaping">
<file name="HTMLPurifier/Filter/ExtractStyleBlocks.php">
<line>123</line>
</file>
</directive>
<directive id="HTML.MaxImgLength">
<file name="HTMLPurifier/HTMLModule/Image.php">
<line>14</line>
</file>
<file name="HTMLPurifier/HTMLModule/SafeEmbed.php">
<line>13</line>
</file>
<file name="HTMLPurifier/HTMLModule/SafeObject.php">
<line>19</line>
</file>
</directive>
<directive id="HTML.TidyLevel">
<file name="HTMLPurifier/HTMLModule/Tidy.php">
<line>45</line>
</file>
</directive>
<directive id="HTML.TidyAdd">
<file name="HTMLPurifier/HTMLModule/Tidy.php">
<line>49</line>
</file>
</directive>
<directive id="HTML.TidyRemove">
<file name="HTMLPurifier/HTMLModule/Tidy.php">
<line>50</line>
</file>
</directive>
<directive id="AutoFormatParam.PurifierLinkifyDocURL">
<file name="HTMLPurifier/Injector/PurifierLinkify.php">
<line>15</line>
</file>
</directive>
<directive id="Core.AggressivelyFixLt">
<file name="HTMLPurifier/Lexer/DOMLex.php">
<line>44</line>
</file>
</directive>
<directive id="Core.DirectLexLineNumberSyncInterval">
<file name="HTMLPurifier/Lexer/DirectLex.php">
<line>70</line>
</file>
</directive>
<directive id="Core.EscapeInvalidTags">
<file name="HTMLPurifier/Strategy/MakeWellFormed.php">
<line>45</line>
</file>
<file name="HTMLPurifier/Strategy/RemoveForeignElements.php">
<line>19</line>
</file>
</directive>
<directive id="Core.RemoveScriptContents">
<file name="HTMLPurifier/Strategy/RemoveForeignElements.php">
<line>25</line>
</file>
</directive>
<directive id="Core.HiddenElements">
<file name="HTMLPurifier/Strategy/RemoveForeignElements.php">
<line>26</line>
</file>
</directive>
<directive id="URI.HostBlacklist">
<file name="HTMLPurifier/URIFilter/HostBlacklist.php">
<line>8</line>
</file>
</directive>
<directive id="URI.MungeResources">
<file name="HTMLPurifier/URIFilter/Munge.php">
<line>14</line>
</file>
</directive>
<directive id="URI.MungeSecretKey">
<file name="HTMLPurifier/URIFilter/Munge.php">
<line>15</line>
</file>
</directive>
</usage>

View File

@ -33,7 +33,7 @@ look something like %Filter.YouTube.Blacklist. While you could technically
set it with ('HTML', 'YouTube.Blacklist'), the logical extension set it with ('HTML', 'YouTube.Blacklist'), the logical extension
('HTML', 'YouTube', 'Blacklist') does not work. ('HTML', 'YouTube', 'Blacklist') does not work.
[more changes coming] The old API will still work, but will emit E_USER_NOTICEs.

View File

@ -8,8 +8,8 @@ require_once '../../library/HTMLPurifier.auto.php';
$config = HTMLPurifier_Config::createDefault(); $config = HTMLPurifier_Config::createDefault();
// configuration goes here: // configuration goes here:
$config->set('Core', 'Encoding', 'UTF-8'); // replace with your encoding $config->set('Core.Encoding', 'UTF-8'); // replace with your encoding
$config->set('HTML', 'Doctype', 'XHTML 1.0 Transitional'); // replace with your doctype $config->set('HTML.Doctype', 'XHTML 1.0 Transitional'); // replace with your doctype
$purifier = new HTMLPurifier($config); $purifier = new HTMLPurifier($config);

View File

@ -17,11 +17,11 @@ function kses($string, $allowed_html, $allowed_protocols = null) {
$allowed_attributes["$element.$attribute"] = true; $allowed_attributes["$element.$attribute"] = true;
} }
} }
$config->set('HTML', 'AllowedElements', $allowed_elements); $config->set('HTML.AllowedElements', $allowed_elements);
$config->set('HTML', 'AllowedAttributes', $allowed_attributes); $config->set('HTML.AllowedAttributes', $allowed_attributes);
$allowed_schemes = array(); $allowed_schemes = array();
if ($allowed_protocols !== null) { if ($allowed_protocols !== null) {
$config->set('URI', 'AllowedSchemes', $allowed_protocols); $config->set('URI.AllowedSchemes', $allowed_protocols);
} }
$purifier = new HTMLPurifier($config); $purifier = new HTMLPurifier($config);
return $purifier->purify($string); return $purifier->purify($string);

View File

@ -128,7 +128,7 @@ class HTMLPurifier
$context->register('Generator', $this->generator); $context->register('Generator', $this->generator);
// set up global context variables // set up global context variables
if ($config->get('Core', 'CollectErrors')) { if ($config->get('Core.CollectErrors')) {
// may get moved out if other facilities use it // may get moved out if other facilities use it
$language_factory = HTMLPurifier_LanguageFactory::instance(); $language_factory = HTMLPurifier_LanguageFactory::instance();
$language = $language_factory->create($config, $context); $language = $language_factory->create($config, $context);

View File

@ -9,7 +9,7 @@ class HTMLPurifier_AttrDef_CSS_Color extends HTMLPurifier_AttrDef
public function validate($color, $config, $context) { public function validate($color, $config, $context) {
static $colors = null; static $colors = null;
if ($colors === null) $colors = $config->get('Core', 'ColorKeywords'); if ($colors === null) $colors = $config->get('Core.ColorKeywords');
$color = trim($color); $color = trim($color);
if ($color === '') return false; if ($color === '') return false;

View File

@ -9,7 +9,7 @@ class HTMLPurifier_AttrDef_HTML_Color extends HTMLPurifier_AttrDef
public function validate($string, $config, $context) { public function validate($string, $config, $context) {
static $colors = null; static $colors = null;
if ($colors === null) $colors = $config->get('Core', 'ColorKeywords'); if ($colors === null) $colors = $config->get('Core.ColorKeywords');
$string = trim($string); $string = trim($string);

View File

@ -12,7 +12,7 @@ class HTMLPurifier_AttrDef_HTML_FrameTarget extends HTMLPurifier_AttrDef_Enum
public function __construct() {} public function __construct() {}
public function validate($string, $config, $context) { public function validate($string, $config, $context) {
if ($this->valid_values === false) $this->valid_values = $config->get('Attr', 'AllowedFrameTargets'); if ($this->valid_values === false) $this->valid_values = $config->get('Attr.AllowedFrameTargets');
return parent::validate($string, $config, $context); return parent::validate($string, $config, $context);
} }

View File

@ -17,18 +17,18 @@ class HTMLPurifier_AttrDef_HTML_ID extends HTMLPurifier_AttrDef
public function validate($id, $config, $context) { public function validate($id, $config, $context) {
if (!$config->get('Attr', 'EnableID')) return false; if (!$config->get('Attr.EnableID')) return false;
$id = trim($id); // trim it first $id = trim($id); // trim it first
if ($id === '') return false; if ($id === '') return false;
$prefix = $config->get('Attr', 'IDPrefix'); $prefix = $config->get('Attr.IDPrefix');
if ($prefix !== '') { if ($prefix !== '') {
$prefix .= $config->get('Attr', 'IDPrefixLocal'); $prefix .= $config->get('Attr.IDPrefixLocal');
// prevent re-appending the prefix // prevent re-appending the prefix
if (strpos($id, $prefix) !== 0) $id = $prefix . $id; if (strpos($id, $prefix) !== 0) $id = $prefix . $id;
} elseif ($config->get('Attr', 'IDPrefixLocal') !== '') { } elseif ($config->get('Attr.IDPrefixLocal') !== '') {
trigger_error('%Attr.IDPrefixLocal cannot be used unless '. trigger_error('%Attr.IDPrefixLocal cannot be used unless '.
'%Attr.IDPrefix is set', E_USER_WARNING); '%Attr.IDPrefix is set', E_USER_WARNING);
} }
@ -51,7 +51,7 @@ class HTMLPurifier_AttrDef_HTML_ID extends HTMLPurifier_AttrDef
$result = ($trim === ''); $result = ($trim === '');
} }
$regexp = $config->get('Attr', 'IDBlacklistRegexp'); $regexp = $config->get('Attr.IDBlacklistRegexp');
if ($regexp && preg_match($regexp, $id)) { if ($regexp && preg_match($regexp, $id)) {
return false; return false;
} }

View File

@ -27,7 +27,7 @@ class HTMLPurifier_AttrDef_HTML_LinkTypes extends HTMLPurifier_AttrDef
public function validate($string, $config, $context) { public function validate($string, $config, $context) {
$allowed = $config->get('Attr', $this->name); $allowed = $config->get('Attr.' . $this->name);
if (empty($allowed)) return false; if (empty($allowed)) return false;
$string = $this->parseCDATA($string); $string = $this->parseCDATA($string);

View File

@ -25,7 +25,7 @@ class HTMLPurifier_AttrDef_URI extends HTMLPurifier_AttrDef
public function validate($uri, $config, $context) { public function validate($uri, $config, $context) {
if ($config->get('URI', 'Disable')) return false; if ($config->get('URI.Disable')) return false;
$uri = $this->parseCDATA($uri); $uri = $this->parseCDATA($uri);

View File

@ -10,7 +10,7 @@ class HTMLPurifier_AttrTransform_BdoDir extends HTMLPurifier_AttrTransform
public function transform($attr, $config, $context) { public function transform($attr, $config, $context) {
if (isset($attr['dir'])) return $attr; if (isset($attr['dir'])) return $attr;
$attr['dir'] = $config->get('Attr', 'DefaultTextDir'); $attr['dir'] = $config->get('Attr.DefaultTextDir');
return $attr; return $attr;
} }

View File

@ -15,21 +15,21 @@ class HTMLPurifier_AttrTransform_ImgRequired extends HTMLPurifier_AttrTransform
$src = true; $src = true;
if (!isset($attr['src'])) { if (!isset($attr['src'])) {
if ($config->get('Core', 'RemoveInvalidImg')) return $attr; if ($config->get('Core.RemoveInvalidImg')) return $attr;
$attr['src'] = $config->get('Attr', 'DefaultInvalidImage'); $attr['src'] = $config->get('Attr.DefaultInvalidImage');
$src = false; $src = false;
} }
if (!isset($attr['alt'])) { if (!isset($attr['alt'])) {
if ($src) { if ($src) {
$alt = $config->get('Attr', 'DefaultImageAlt'); $alt = $config->get('Attr.DefaultImageAlt');
if ($alt === null) { if ($alt === null) {
$attr['alt'] = basename($attr['src']); $attr['alt'] = basename($attr['src']);
} else { } else {
$attr['alt'] = $alt; $attr['alt'] = $alt;
} }
} else { } else {
$attr['alt'] = $config->get('Attr', 'DefaultInvalidImageAlt'); $attr['alt'] = $config->get('Attr.DefaultInvalidImageAlt');
} }
} }

View File

@ -154,7 +154,7 @@ class HTMLPurifier_CSSDefinition extends HTMLPurifier_Definition
new HTMLPurifier_AttrDef_CSS_Percentage(true), new HTMLPurifier_AttrDef_CSS_Percentage(true),
new HTMLPurifier_AttrDef_Enum(array('auto')) new HTMLPurifier_AttrDef_Enum(array('auto'))
)); ));
$max = $config->get('CSS', 'MaxImgLength'); $max = $config->get('CSS.MaxImgLength');
$this->info['width'] = $this->info['width'] =
$this->info['height'] = $this->info['height'] =
@ -211,15 +211,15 @@ class HTMLPurifier_CSSDefinition extends HTMLPurifier_Definition
// partial support // partial support
$this->info['white-space'] = new HTMLPurifier_AttrDef_Enum(array('nowrap')); $this->info['white-space'] = new HTMLPurifier_AttrDef_Enum(array('nowrap'));
if ($config->get('CSS', 'Proprietary')) { if ($config->get('CSS.Proprietary')) {
$this->doSetupProprietary($config); $this->doSetupProprietary($config);
} }
if ($config->get('CSS', 'AllowTricky')) { if ($config->get('CSS.AllowTricky')) {
$this->doSetupTricky($config); $this->doSetupTricky($config);
} }
$allow_important = $config->get('CSS', 'AllowImportant'); $allow_important = $config->get('CSS.AllowImportant');
// wrap all attr-defs with decorator that handles !important // wrap all attr-defs with decorator that handles !important
foreach ($this->info as $k => $v) { foreach ($this->info as $k => $v) {
$this->info[$k] = new HTMLPurifier_AttrDef_CSS_ImportantDecorator($v, $allow_important); $this->info[$k] = new HTMLPurifier_AttrDef_CSS_ImportantDecorator($v, $allow_important);
@ -272,7 +272,7 @@ class HTMLPurifier_CSSDefinition extends HTMLPurifier_Definition
// setup allowed elements // setup allowed elements
$support = "(for information on implementing this, see the ". $support = "(for information on implementing this, see the ".
"support forums) "; "support forums) ";
$allowed_attributes = $config->get('CSS', 'AllowedProperties'); $allowed_attributes = $config->get('CSS.AllowedProperties');
if ($allowed_attributes !== null) { if ($allowed_attributes !== null) {
foreach ($this->info as $name => $d) { foreach ($this->info as $name => $d) {
if(!isset($allowed_attributes[$name])) unset($this->info[$name]); if(!isset($allowed_attributes[$name])) unset($this->info[$name]);

View File

@ -59,7 +59,7 @@ class HTMLPurifier_ChildDef_Required extends HTMLPurifier_ChildDef
$all_whitespace = true; $all_whitespace = true;
// some configuration // some configuration
$escape_invalid_children = $config->get('Core', 'EscapeInvalidChildren'); $escape_invalid_children = $config->get('Core.EscapeInvalidChildren');
// generator // generator
$gen = new HTMLPurifier_Generator($config, $context); $gen = new HTMLPurifier_Generator($config, $context);

View File

@ -68,6 +68,18 @@ class HTMLPurifier_Config
*/ */
protected $plist; protected $plist;
/**
* Whether or not a set is taking place due to an
* alias lookup.
*/
private $aliasMode;
/**
* Set to false if you do not want line and file numbers in errors
* (useful when unit testing)
*/
public $chatty = true;
/** /**
* @param $definition HTMLPurifier_ConfigSchema that defines what directives * @param $definition HTMLPurifier_ConfigSchema that defines what directives
* are allowed. * are allowed.
@ -117,18 +129,21 @@ class HTMLPurifier_Config
* @param $namespace String namespace * @param $namespace String namespace
* @param $key String key * @param $key String key
*/ */
public function get($namespace, $directive) { public function get($key, $a = null) {
$key = "$namespace.$directive"; if ($a !== null) {
$this->triggerError("Using deprecated API: use \$config->get('$key.$a') instead", E_USER_WARNING);
$key = "$key.$a";
}
if (!$this->finalized) $this->autoFinalize ? $this->finalize() : $this->plist->squash(true); if (!$this->finalized) $this->autoFinalize ? $this->finalize() : $this->plist->squash(true);
if (!isset($this->def->info[$key])) { if (!isset($this->def->info[$key])) {
// can't add % due to SimpleTest bug // can't add % due to SimpleTest bug
trigger_error('Cannot retrieve value of undefined directive ' . htmlspecialchars($key), $this->triggerError('Cannot retrieve value of undefined directive ' . htmlspecialchars($key),
E_USER_WARNING); E_USER_WARNING);
return; return;
} }
if (isset($this->def->info[$key]->isAlias)) { if (isset($this->def->info[$key]->isAlias)) {
$d = $this->def->info[$key]; $d = $this->def->info[$key];
trigger_error('Cannot get value from aliased directive, use real name ' . $d->key, $this->triggerError('Cannot get value from aliased directive, use real name ' . $d->key,
E_USER_ERROR); E_USER_ERROR);
return; return;
} }
@ -143,7 +158,7 @@ class HTMLPurifier_Config
if (!$this->finalized) $this->autoFinalize ? $this->finalize() : $this->plist->squash(true); if (!$this->finalized) $this->autoFinalize ? $this->finalize() : $this->plist->squash(true);
$full = $this->getAll(); $full = $this->getAll();
if (!isset($full[$namespace])) { if (!isset($full[$namespace])) {
trigger_error('Cannot retrieve undefined namespace ' . htmlspecialchars($namespace), $this->triggerError('Cannot retrieve undefined namespace ' . htmlspecialchars($namespace),
E_USER_WARNING); E_USER_WARNING);
return; return;
} }
@ -196,26 +211,34 @@ class HTMLPurifier_Config
* @param $key String key * @param $key String key
* @param $value Mixed value * @param $value Mixed value
*/ */
public function set($namespace, $directive, $value, $from_alias = false) { public function set($key, $value, $a = null) {
$key = "$namespace.$directive"; if (strpos($key, '.') === false) {
$namespace = $key;
$directive = $value;
$value = $a;
$key = "$key.$directive";
$this->triggerError("Using deprecated API: use \$config->set('$key', ...) instead", E_USER_NOTICE);
} else {
list($namespace) = explode('.', $key);
}
if ($this->isFinalized('Cannot set directive after finalization')) return; if ($this->isFinalized('Cannot set directive after finalization')) return;
if (!isset($this->def->info[$key])) { if (!isset($this->def->info[$key])) {
trigger_error('Cannot set undefined directive ' . htmlspecialchars($key) . ' to value', $this->triggerError('Cannot set undefined directive ' . htmlspecialchars($key) . ' to value',
E_USER_WARNING); E_USER_WARNING);
return; return;
} }
$def = $this->def->info[$key]; $def = $this->def->info[$key];
if (isset($def->isAlias)) { if (isset($def->isAlias)) {
if ($from_alias) { if ($this->aliasMode) {
trigger_error('Double-aliases not allowed, please fix '. $this->triggerError('Double-aliases not allowed, please fix '.
'ConfigSchema bug with' . $key, E_USER_ERROR); 'ConfigSchema bug with' . $key, E_USER_ERROR);
return; return;
} }
list($alias_namespace, $alias_directive) = explode('.', $def->key, 2); $this->aliasMode = true;
$this->set($alias_namespace, $alias_directive, $this->set($def->key, $value);
$value, true); $this->aliasMode = false;
trigger_error("$key is an alias, preferred directive name is {$def->key}", E_USER_NOTICE); $this->triggerError("$key is an alias, preferred directive name is {$def->key}", E_USER_NOTICE);
return; return;
} }
@ -233,7 +256,7 @@ class HTMLPurifier_Config
try { try {
$value = $this->parser->parse($value, $type, $allow_null); $value = $this->parser->parse($value, $type, $allow_null);
} catch (HTMLPurifier_VarParserException $e) { } catch (HTMLPurifier_VarParserException $e) {
trigger_error('Value for ' . $key . ' is of invalid type, should be ' . HTMLPurifier_VarParser::getTypeName($type), E_USER_WARNING); $this->triggerError('Value for ' . $key . ' is of invalid type, should be ' . HTMLPurifier_VarParser::getTypeName($type), E_USER_WARNING);
return; return;
} }
if (is_string($value) && is_object($def)) { if (is_string($value) && is_object($def)) {
@ -243,7 +266,7 @@ class HTMLPurifier_Config
} }
// check to see if the value is allowed // check to see if the value is allowed
if (isset($def->allowed) && !isset($def->allowed[$value])) { if (isset($def->allowed) && !isset($def->allowed[$value])) {
trigger_error('Value not supported, valid values are: ' . $this->triggerError('Value not supported, valid values are: ' .
$this->_listify($def->allowed), E_USER_WARNING); $this->_listify($def->allowed), E_USER_WARNING);
return; return;
} }
@ -330,7 +353,7 @@ class HTMLPurifier_Config
} }
// quick abort if raw // quick abort if raw
if ($raw) { if ($raw) {
if (is_null($this->get($type, 'DefinitionID'))) { if (is_null($this->get($type . '.DefinitionID'))) {
// fatally error out if definition ID not set // fatally error out if definition ID not set
throw new HTMLPurifier_Exception("Cannot retrieve raw version without specifying %$type.DefinitionID"); throw new HTMLPurifier_Exception("Cannot retrieve raw version without specifying %$type.DefinitionID");
} }
@ -354,12 +377,12 @@ class HTMLPurifier_Config
$key = str_replace('_', '.', $key); $key = str_replace('_', '.', $key);
if (strpos($key, '.') !== false) { if (strpos($key, '.') !== false) {
list($namespace, $directive) = explode(".", $key, 2); list($namespace, $directive) = explode(".", $key, 2);
$this->set($namespace, $directive, $value); $this->set($key, $value);
} else { } else {
$namespace = $key; $namespace = $key;
$namespace_values = $value; $namespace_values = $value;
foreach ($namespace_values as $directive => $value) { foreach ($namespace_values as $directive => $value) {
$this->set($namespace, $directive, $value); $this->set($namespace .'.'. $directive, $value);
} }
} }
} }
@ -472,7 +495,7 @@ class HTMLPurifier_Config
*/ */
public function isFinalized($error = false) { public function isFinalized($error = false) {
if ($this->finalized && $error) { if ($this->finalized && $error) {
trigger_error($error, E_USER_ERROR); $this->triggerError($error, E_USER_ERROR);
} }
return $this->finalized; return $this->finalized;
} }
@ -492,6 +515,23 @@ class HTMLPurifier_Config
$this->finalized = true; $this->finalized = true;
} }
/**
* Produces a nicely formatted error message by supplying the
* stack frame information from two levels up and OUTSIDE of
* HTMLPurifier_Config.
*/
protected function triggerError($msg, $no) {
// determine previous stack frame
$backtrace = debug_backtrace();
if ($this->chatty && isset($backtrace[1])) {
$frame = $backtrace[1];
$extra = " on line {$frame['line']} in file {$frame['file']}";
} else {
$extra = '';
}
trigger_error($msg . $extra, $no);
}
} }
// vim: et sw=4 sts=4 // vim: et sw=4 sts=4

View File

@ -28,7 +28,7 @@ abstract class HTMLPurifier_DefinitionCache
public function generateKey($config) { public function generateKey($config) {
return $config->version . ',' . // possibly replace with function calls return $config->version . ',' . // possibly replace with function calls
$config->getBatchSerial($this->type) . ',' . $config->getBatchSerial($this->type) . ',' .
$config->get($this->type, 'DefinitionRev'); $config->get($this->type . '.DefinitionRev');
} }
/** /**
@ -46,7 +46,7 @@ abstract class HTMLPurifier_DefinitionCache
// versions match, ids match, check revision number // versions match, ids match, check revision number
if ( if (
$hash == $config->getBatchSerial($this->type) && $hash == $config->getBatchSerial($this->type) &&
$revision < $config->get($this->type, 'DefinitionRev') $revision < $config->get($this->type . '.DefinitionRev')
) return true; ) return true;
return false; return false;
} }

View File

@ -88,7 +88,7 @@ class HTMLPurifier_DefinitionCache_Serializer extends
* @todo Make protected * @todo Make protected
*/ */
public function generateBaseDirectoryPath($config) { public function generateBaseDirectoryPath($config) {
$base = $config->get('Cache', 'SerializerPath'); $base = $config->get('Cache.SerializerPath');
$base = is_null($base) ? HTMLPURIFIER_PREFIX . '/HTMLPurifier/DefinitionCache/Serializer' : $base; $base = is_null($base) ? HTMLPURIFIER_PREFIX . '/HTMLPurifier/DefinitionCache/Serializer' : $base;
return $base; return $base;
} }

View File

@ -46,7 +46,7 @@ class HTMLPurifier_DefinitionCacheFactory
* @param $config Instance of HTMLPurifier_Config * @param $config Instance of HTMLPurifier_Config
*/ */
public function create($type, $config) { public function create($type, $config) {
$method = $config->get('Cache', 'DefinitionImpl'); $method = $config->get('Cache.DefinitionImpl');
if ($method === null) { if ($method === null) {
return new HTMLPurifier_DefinitionCache_Null($type); return new HTMLPurifier_DefinitionCache_Null($type);
} }

View File

@ -80,17 +80,17 @@ class HTMLPurifier_DoctypeRegistry
*/ */
public function getDoctypeFromConfig($config) { public function getDoctypeFromConfig($config) {
// recommended test // recommended test
$doctype = $config->get('HTML', 'Doctype'); $doctype = $config->get('HTML.Doctype');
if (!empty($doctype)) return $doctype; if (!empty($doctype)) return $doctype;
$doctype = $config->get('HTML', 'CustomDoctype'); $doctype = $config->get('HTML.CustomDoctype');
if (!empty($doctype)) return $doctype; if (!empty($doctype)) return $doctype;
// backwards-compatibility // backwards-compatibility
if ($config->get('HTML', 'XHTML')) { if ($config->get('HTML.XHTML')) {
$doctype = 'XHTML 1.0'; $doctype = 'XHTML 1.0';
} else { } else {
$doctype = 'HTML 4.01'; $doctype = 'HTML 4.01';
} }
if ($config->get('HTML', 'Strict')) { if ($config->get('HTML.Strict')) {
$doctype .= ' Strict'; $doctype .= ' Strict';
} else { } else {
$doctype .= ' Transitional'; $doctype .= ' Transitional';

View File

@ -264,12 +264,12 @@ class HTMLPurifier_Encoder
* Converts a string to UTF-8 based on configuration. * Converts a string to UTF-8 based on configuration.
*/ */
public static function convertToUTF8($str, $config, $context) { public static function convertToUTF8($str, $config, $context) {
$encoding = $config->get('Core', 'Encoding'); $encoding = $config->get('Core.Encoding');
if ($encoding === 'utf-8') return $str; if ($encoding === 'utf-8') return $str;
static $iconv = null; static $iconv = null;
if ($iconv === null) $iconv = function_exists('iconv'); if ($iconv === null) $iconv = function_exists('iconv');
set_error_handler(array('HTMLPurifier_Encoder', 'muteErrorHandler')); set_error_handler(array('HTMLPurifier_Encoder', 'muteErrorHandler'));
if ($iconv && !$config->get('Test', 'ForceNoIconv')) { if ($iconv && !$config->get('Test.ForceNoIconv')) {
$str = iconv($encoding, 'utf-8//IGNORE', $str); $str = iconv($encoding, 'utf-8//IGNORE', $str);
if ($str === false) { if ($str === false) {
// $encoding is not a valid encoding // $encoding is not a valid encoding
@ -297,15 +297,15 @@ class HTMLPurifier_Encoder
* characters being omitted. * characters being omitted.
*/ */
public static function convertFromUTF8($str, $config, $context) { public static function convertFromUTF8($str, $config, $context) {
$encoding = $config->get('Core', 'Encoding'); $encoding = $config->get('Core.Encoding');
if ($encoding === 'utf-8') return $str; if ($encoding === 'utf-8') return $str;
static $iconv = null; static $iconv = null;
if ($iconv === null) $iconv = function_exists('iconv'); if ($iconv === null) $iconv = function_exists('iconv');
if ($escape = $config->get('Core', 'EscapeNonASCIICharacters')) { if ($escape = $config->get('Core.EscapeNonASCIICharacters')) {
$str = HTMLPurifier_Encoder::convertToASCIIDumbLossless($str); $str = HTMLPurifier_Encoder::convertToASCIIDumbLossless($str);
} }
set_error_handler(array('HTMLPurifier_Encoder', 'muteErrorHandler')); set_error_handler(array('HTMLPurifier_Encoder', 'muteErrorHandler'));
if ($iconv && !$config->get('Test', 'ForceNoIconv')) { if ($iconv && !$config->get('Test.ForceNoIconv')) {
// Undo our previous fix in convertToUTF8, otherwise iconv will barf // Undo our previous fix in convertToUTF8, otherwise iconv will barf
$ascii_fix = HTMLPurifier_Encoder::testEncodingSupportsASCII($encoding); $ascii_fix = HTMLPurifier_Encoder::testEncodingSupportsASCII($encoding);
if (!$escape && !empty($ascii_fix)) { if (!$escape && !empty($ascii_fix)) {

View File

@ -38,7 +38,7 @@ class HTMLPurifier_Filter_ExtractStyleBlocks extends HTMLPurifier_Filter
* @todo Extend to indicate non-text/css style blocks * @todo Extend to indicate non-text/css style blocks
*/ */
public function preFilter($html, $config, $context) { public function preFilter($html, $config, $context) {
$tidy = $config->get('FilterParam', 'ExtractStyleBlocksTidyImpl'); $tidy = $config->get('FilterParam.ExtractStyleBlocksTidyImpl');
if ($tidy !== null) $this->_tidy = $tidy; if ($tidy !== null) $this->_tidy = $tidy;
$html = preg_replace_callback('#<style(?:\s.*)?>(.+)</style>#isU', array($this, 'styleCallback'), $html); $html = preg_replace_callback('#<style(?:\s.*)?>(.+)</style>#isU', array($this, 'styleCallback'), $html);
$style_blocks = $this->_styleMatches; $style_blocks = $this->_styleMatches;
@ -62,7 +62,7 @@ class HTMLPurifier_Filter_ExtractStyleBlocks extends HTMLPurifier_Filter
*/ */
public function cleanCSS($css, $config, $context) { public function cleanCSS($css, $config, $context) {
// prepare scope // prepare scope
$scope = $config->get('FilterParam', 'ExtractStyleBlocksScope'); $scope = $config->get('FilterParam.ExtractStyleBlocksScope');
if ($scope !== null) { if ($scope !== null) {
$scopes = array_map('trim', explode(',', $scope)); $scopes = array_map('trim', explode(',', $scope));
} else { } else {
@ -120,7 +120,7 @@ class HTMLPurifier_Filter_ExtractStyleBlocks extends HTMLPurifier_Filter
$css = $this->_tidy->print->plain(); $css = $this->_tidy->print->plain();
// we are going to escape any special characters <>& to ensure // we are going to escape any special characters <>& to ensure
// that no funny business occurs (i.e. </style> in a font-family prop). // that no funny business occurs (i.e. </style> in a font-family prop).
if ($config->get('FilterParam', 'ExtractStyleBlocksEscaping')) { if ($config->get('FilterParam.ExtractStyleBlocksEscaping')) {
$css = str_replace( $css = str_replace(
array('<', '>', '&'), array('<', '>', '&'),
array('\3C ', '\3E ', '\26 '), array('\3C ', '\3E ', '\26 '),

View File

@ -42,8 +42,8 @@ class HTMLPurifier_Generator
*/ */
public function __construct($config, $context) { public function __construct($config, $context) {
$this->config = $config; $this->config = $config;
$this->_scriptFix = $config->get('Output', 'CommentScriptContents'); $this->_scriptFix = $config->get('Output.CommentScriptContents');
$this->_sortAttr = $config->get('Output', 'SortAttr'); $this->_sortAttr = $config->get('Output.SortAttr');
$this->_def = $config->getHTMLDefinition(); $this->_def = $config->getHTMLDefinition();
$this->_xhtml = $this->_def->doctype->xml; $this->_xhtml = $this->_def->doctype->xml;
} }
@ -72,7 +72,7 @@ class HTMLPurifier_Generator
} }
// Tidy cleanup // Tidy cleanup
if (extension_loaded('tidy') && $this->config->get('Output', 'TidyFormat')) { if (extension_loaded('tidy') && $this->config->get('Output.TidyFormat')) {
$tidy = new Tidy; $tidy = new Tidy;
$tidy->parseString($html, array( $tidy->parseString($html, array(
'indent'=> true, 'indent'=> true,
@ -86,7 +86,7 @@ class HTMLPurifier_Generator
} }
// Normalize newlines to system defined value // Normalize newlines to system defined value
$nl = $this->config->get('Output', 'Newline'); $nl = $this->config->get('Output.Newline');
if ($nl === null) $nl = PHP_EOL; if ($nl === null) $nl = PHP_EOL;
if ($nl !== "\n") $html = str_replace("\n", $nl, $html); if ($nl !== "\n") $html = str_replace("\n", $nl, $html);
return $html; return $html;

View File

@ -219,7 +219,7 @@ class HTMLPurifier_HTMLDefinition extends HTMLPurifier_Definition
*/ */
protected function setupConfigStuff($config) { protected function setupConfigStuff($config) {
$block_wrapper = $config->get('HTML', 'BlockWrapper'); $block_wrapper = $config->get('HTML.BlockWrapper');
if (isset($this->info_content_sets['Block'][$block_wrapper])) { if (isset($this->info_content_sets['Block'][$block_wrapper])) {
$this->info_block_wrapper = $block_wrapper; $this->info_block_wrapper = $block_wrapper;
} else { } else {
@ -227,7 +227,7 @@ class HTMLPurifier_HTMLDefinition extends HTMLPurifier_Definition
E_USER_ERROR); E_USER_ERROR);
} }
$parent = $config->get('HTML', 'Parent'); $parent = $config->get('HTML.Parent');
$def = $this->manager->getElement($parent, true); $def = $this->manager->getElement($parent, true);
if ($def) { if ($def) {
$this->info_parent = $parent; $this->info_parent = $parent;
@ -244,11 +244,11 @@ class HTMLPurifier_HTMLDefinition extends HTMLPurifier_Definition
// setup allowed elements ----------------------------------------- // setup allowed elements -----------------------------------------
$allowed_elements = $config->get('HTML', 'AllowedElements'); $allowed_elements = $config->get('HTML.AllowedElements');
$allowed_attributes = $config->get('HTML', 'AllowedAttributes'); // retrieve early $allowed_attributes = $config->get('HTML.AllowedAttributes'); // retrieve early
if (!is_array($allowed_elements) && !is_array($allowed_attributes)) { if (!is_array($allowed_elements) && !is_array($allowed_attributes)) {
$allowed = $config->get('HTML', 'Allowed'); $allowed = $config->get('HTML.Allowed');
if (is_string($allowed)) { if (is_string($allowed)) {
list($allowed_elements, $allowed_attributes) = $this->parseTinyMCEAllowedList($allowed); list($allowed_elements, $allowed_attributes) = $this->parseTinyMCEAllowedList($allowed);
} }
@ -334,8 +334,8 @@ class HTMLPurifier_HTMLDefinition extends HTMLPurifier_Definition
// setup forbidden elements --------------------------------------- // setup forbidden elements ---------------------------------------
$forbidden_elements = $config->get('HTML', 'ForbiddenElements'); $forbidden_elements = $config->get('HTML.ForbiddenElements');
$forbidden_attributes = $config->get('HTML', 'ForbiddenAttributes'); $forbidden_attributes = $config->get('HTML.ForbiddenAttributes');
foreach ($this->info as $tag => $info) { foreach ($this->info as $tag => $info) {
if (isset($forbidden_elements[$tag])) { if (isset($forbidden_elements[$tag])) {

View File

@ -11,7 +11,7 @@ class HTMLPurifier_HTMLModule_Image extends HTMLPurifier_HTMLModule
public $name = 'Image'; public $name = 'Image';
public function setup($config) { public function setup($config) {
$max = $config->get('HTML', 'MaxImgLength'); $max = $config->get('HTML.MaxImgLength');
$img = $this->addElement( $img = $this->addElement(
'img', 'Inline', 'Empty', 'Common', 'img', 'Inline', 'Empty', 'Common',
array( array(
@ -24,7 +24,7 @@ class HTMLPurifier_HTMLModule_Image extends HTMLPurifier_HTMLModule
'src*' => new HTMLPurifier_AttrDef_URI(true), // embedded 'src*' => new HTMLPurifier_AttrDef_URI(true), // embedded
) )
); );
if ($max === null || $config->get('HTML', 'Trusted')) { if ($max === null || $config->get('HTML.Trusted')) {
$img->attr['height'] = $img->attr['height'] =
$img->attr['width'] = 'Length'; $img->attr['width'] = 'Length';
} }

View File

@ -10,7 +10,7 @@ class HTMLPurifier_HTMLModule_SafeEmbed extends HTMLPurifier_HTMLModule
public function setup($config) { public function setup($config) {
$max = $config->get('HTML', 'MaxImgLength'); $max = $config->get('HTML.MaxImgLength');
$embed = $this->addElement( $embed = $this->addElement(
'embed', 'Inline', 'Empty', 'Common', 'embed', 'Inline', 'Empty', 'Common',
array( array(

View File

@ -16,7 +16,7 @@ class HTMLPurifier_HTMLModule_SafeObject extends HTMLPurifier_HTMLModule
// These definitions are not intrinsically safe: the attribute transforms // These definitions are not intrinsically safe: the attribute transforms
// are a vital part of ensuring safety. // are a vital part of ensuring safety.
$max = $config->get('HTML', 'MaxImgLength'); $max = $config->get('HTML.MaxImgLength');
$object = $this->addElement( $object = $this->addElement(
'object', 'object',
'Inline', 'Inline',

View File

@ -42,12 +42,12 @@ class HTMLPurifier_HTMLModule_Tidy extends HTMLPurifier_HTMLModule
$this->makeFixesForLevel($fixes); $this->makeFixesForLevel($fixes);
// figure out which fixes to use // figure out which fixes to use
$level = $config->get('HTML', 'TidyLevel'); $level = $config->get('HTML.TidyLevel');
$fixes_lookup = $this->getFixesForLevel($level); $fixes_lookup = $this->getFixesForLevel($level);
// get custom fix declarations: these need namespace processing // get custom fix declarations: these need namespace processing
$add_fixes = $config->get('HTML', 'TidyAdd'); $add_fixes = $config->get('HTML.TidyAdd');
$remove_fixes = $config->get('HTML', 'TidyRemove'); $remove_fixes = $config->get('HTML.TidyRemove');
foreach ($fixes as $name => $fix) { foreach ($fixes as $name => $fix) {
// needs to be refactored a little to implement globbing // needs to be refactored a little to implement globbing

View File

@ -199,15 +199,15 @@ class HTMLPurifier_HTMLModuleManager
*/ */
public function setup($config) { public function setup($config) {
$this->trusted = $config->get('HTML', 'Trusted'); $this->trusted = $config->get('HTML.Trusted');
// generate // generate
$this->doctype = $this->doctypes->make($config); $this->doctype = $this->doctypes->make($config);
$modules = $this->doctype->modules; $modules = $this->doctype->modules;
// take out the default modules that aren't allowed // take out the default modules that aren't allowed
$lookup = $config->get('HTML', 'AllowedModules'); $lookup = $config->get('HTML.AllowedModules');
$special_cases = $config->get('HTML', 'CoreModules'); $special_cases = $config->get('HTML.CoreModules');
if (is_array($lookup)) { if (is_array($lookup)) {
foreach ($modules as $k => $m) { foreach ($modules as $k => $m) {
@ -218,15 +218,15 @@ class HTMLPurifier_HTMLModuleManager
// add proprietary module (this gets special treatment because // add proprietary module (this gets special treatment because
// it is completely removed from doctypes, etc.) // it is completely removed from doctypes, etc.)
if ($config->get('HTML', 'Proprietary')) { if ($config->get('HTML.Proprietary')) {
$modules[] = 'Proprietary'; $modules[] = 'Proprietary';
} }
// add SafeObject/Safeembed modules // add SafeObject/Safeembed modules
if ($config->get('HTML', 'SafeObject')) { if ($config->get('HTML.SafeObject')) {
$modules[] = 'SafeObject'; $modules[] = 'SafeObject';
} }
if ($config->get('HTML', 'SafeEmbed')) { if ($config->get('HTML.SafeEmbed')) {
$modules[] = 'SafeEmbed'; $modules[] = 'SafeEmbed';
} }

View File

@ -23,7 +23,7 @@ class HTMLPurifier_IDAccumulator
*/ */
public static function build($config, $context) { public static function build($config, $context) {
$id_accumulator = new HTMLPurifier_IDAccumulator(); $id_accumulator = new HTMLPurifier_IDAccumulator();
$id_accumulator->load($config->get('Attr', 'IDBlacklist')); $id_accumulator->load($config->get('Attr.IDBlacklist'));
return $id_accumulator; return $id_accumulator;
} }

View File

@ -12,7 +12,7 @@ class HTMLPurifier_Injector_PurifierLinkify extends HTMLPurifier_Injector
public $needed = array('a' => array('href')); public $needed = array('a' => array('href'));
public function prepare($config, $context) { public function prepare($config, $context) {
$this->docURL = $config->get('AutoFormatParam', 'PurifierLinkifyDocURL'); $this->docURL = $config->get('AutoFormatParam.PurifierLinkifyDocURL');
return parent::prepare($config, $context); return parent::prepare($config, $context);
} }

View File

@ -85,7 +85,7 @@ class HTMLPurifier_LanguageFactory
// validate language code // validate language code
if ($code === false) { if ($code === false) {
$code = $this->validator->validate( $code = $this->validator->validate(
$config->get('Core', 'Language'), $config, $context $config->get('Core.Language'), $config, $context
); );
} else { } else {
$code = $this->validator->validate($code, $config, $context); $code = $this->validator->validate($code, $config, $context);

View File

@ -73,12 +73,12 @@ class HTMLPurifier_Lexer
HTMLPurifier_Lexer::create() is deprecated, please instead HTMLPurifier_Lexer::create() is deprecated, please instead
use %Core.LexerImpl", E_USER_WARNING); use %Core.LexerImpl", E_USER_WARNING);
} else { } else {
$lexer = $config->get('Core', 'LexerImpl'); $lexer = $config->get('Core.LexerImpl');
} }
$needs_tracking = $needs_tracking =
$config->get('Core', 'MaintainLineNumbers') || $config->get('Core.MaintainLineNumbers') ||
$config->get('Core', 'CollectErrors'); $config->get('Core.CollectErrors');
$inst = null; $inst = null;
if (is_object($lexer)) { if (is_object($lexer)) {
@ -255,7 +255,7 @@ class HTMLPurifier_Lexer
$html = str_replace("\r\n", "\n", $html); $html = str_replace("\r\n", "\n", $html);
$html = str_replace("\r", "\n", $html); $html = str_replace("\r", "\n", $html);
if ($config->get('HTML', 'Trusted')) { if ($config->get('HTML.Trusted')) {
// escape convoluted CDATA // escape convoluted CDATA
$html = $this->escapeCommentedCDATA($html); $html = $this->escapeCommentedCDATA($html);
} }
@ -264,7 +264,7 @@ class HTMLPurifier_Lexer
$html = $this->escapeCDATA($html); $html = $this->escapeCDATA($html);
// extract body from document if applicable // extract body from document if applicable
if ($config->get('Core', 'ConvertDocumentToFragment')) { if ($config->get('Core.ConvertDocumentToFragment')) {
$html = $this->extractBody($html); $html = $this->extractBody($html);
} }

View File

@ -41,7 +41,7 @@ class HTMLPurifier_Lexer_DOMLex extends HTMLPurifier_Lexer
// attempt to armor stray angled brackets that cannot possibly // attempt to armor stray angled brackets that cannot possibly
// form tags and thus are probably being used as emoticons // form tags and thus are probably being used as emoticons
if ($config->get('Core', 'AggressivelyFixLt')) { if ($config->get('Core.AggressivelyFixLt')) {
$char = '[^a-z!\/]'; $char = '[^a-z!\/]';
$comment = "/<!--(.*?)(-->|\z)/is"; $comment = "/<!--(.*?)(-->|\z)/is";
$html = preg_replace_callback($comment, array($this, 'callbackArmorCommentEntities'), $html); $html = preg_replace_callback($comment, array($this, 'callbackArmorCommentEntities'), $html);

View File

@ -33,7 +33,7 @@ class HTMLPurifier_Lexer_DirectLex extends HTMLPurifier_Lexer
// special normalization for script tags without any armor // special normalization for script tags without any armor
// our "armor" heurstic is a < sign any number of whitespaces after // our "armor" heurstic is a < sign any number of whitespaces after
// the first script tag // the first script tag
if ($config->get('HTML', 'Trusted')) { if ($config->get('HTML.Trusted')) {
$html = preg_replace_callback('#(<script[^>]*>)(\s*[^<].+?)(</script>)#si', $html = preg_replace_callback('#(<script[^>]*>)(\s*[^<].+?)(</script>)#si',
array($this, 'scriptCallback'), $html); array($this, 'scriptCallback'), $html);
} }
@ -45,12 +45,12 @@ class HTMLPurifier_Lexer_DirectLex extends HTMLPurifier_Lexer
$array = array(); // result array $array = array(); // result array
// This is also treated to mean maintain *column* numbers too // This is also treated to mean maintain *column* numbers too
$maintain_line_numbers = $config->get('Core', 'MaintainLineNumbers'); $maintain_line_numbers = $config->get('Core.MaintainLineNumbers');
if ($maintain_line_numbers === null) { if ($maintain_line_numbers === null) {
// automatically determine line numbering by checking // automatically determine line numbering by checking
// if error collection is on // if error collection is on
$maintain_line_numbers = $config->get('Core', 'CollectErrors'); $maintain_line_numbers = $config->get('Core.CollectErrors');
} }
if ($maintain_line_numbers) { if ($maintain_line_numbers) {
@ -67,10 +67,10 @@ class HTMLPurifier_Lexer_DirectLex extends HTMLPurifier_Lexer
$nl = "\n"; $nl = "\n";
// how often to manually recalculate. This will ALWAYS be right, // how often to manually recalculate. This will ALWAYS be right,
// but it's pretty wasteful. Set to 0 to turn off // but it's pretty wasteful. Set to 0 to turn off
$synchronize_interval = $config->get('Core', 'DirectLexLineNumberSyncInterval'); $synchronize_interval = $config->get('Core.DirectLexLineNumberSyncInterval');
$e = false; $e = false;
if ($config->get('Core', 'CollectErrors')) { if ($config->get('Core.CollectErrors')) {
$e =& $context->get('ErrorCollector'); $e =& $context->get('ErrorCollector');
} }
@ -345,7 +345,7 @@ class HTMLPurifier_Lexer_DirectLex extends HTMLPurifier_Lexer
if ($string == '') return array(); // no attributes if ($string == '') return array(); // no attributes
$e = false; $e = false;
if ($config->get('Core', 'CollectErrors')) { if ($config->get('Core.CollectErrors')) {
$e =& $context->get('ErrorCollector'); $e =& $context->get('ErrorCollector');
} }

View File

@ -91,7 +91,7 @@ class HTMLPurifier_Printer_ConfigForm extends HTMLPurifier_Printer
$all = array(); $all = array();
foreach ($allowed as $key) { foreach ($allowed as $key) {
list($ns, $directive) = $key; list($ns, $directive) = $key;
$all[$ns][$directive] = $config->get($ns, $directive); $all[$ns][$directive] = $config->get($ns .'.'. $directive);
} }
$ret = ''; $ret = '';

View File

@ -42,7 +42,7 @@ class HTMLPurifier_Strategy_MakeWellFormed extends HTMLPurifier_Strategy
// local variables // local variables
$generator = new HTMLPurifier_Generator($config, $context); $generator = new HTMLPurifier_Generator($config, $context);
$escape_invalid_tags = $config->get('Core', 'EscapeInvalidTags'); $escape_invalid_tags = $config->get('Core.EscapeInvalidTags');
$e = $context->get('ErrorCollector', true); $e = $context->get('ErrorCollector', true);
$t = false; // token index $t = false; // token index
$i = false; // injector index $i = false; // injector index

View File

@ -16,14 +16,14 @@ class HTMLPurifier_Strategy_RemoveForeignElements extends HTMLPurifier_Strategy
$generator = new HTMLPurifier_Generator($config, $context); $generator = new HTMLPurifier_Generator($config, $context);
$result = array(); $result = array();
$escape_invalid_tags = $config->get('Core', 'EscapeInvalidTags'); $escape_invalid_tags = $config->get('Core.EscapeInvalidTags');
$remove_invalid_img = $config->get('Core', 'RemoveInvalidImg'); $remove_invalid_img = $config->get('Core.RemoveInvalidImg');
// currently only used to determine if comments should be kept // currently only used to determine if comments should be kept
$trusted = $config->get('HTML', 'Trusted'); $trusted = $config->get('HTML.Trusted');
$remove_script_contents = $config->get('Core', 'RemoveScriptContents'); $remove_script_contents = $config->get('Core.RemoveScriptContents');
$hidden_elements = $config->get('Core', 'HiddenElements'); $hidden_elements = $config->get('Core.HiddenElements');
// remove script contents compatibility // remove script contents compatibility
if ($remove_script_contents === true) { if ($remove_script_contents === true) {
@ -44,7 +44,7 @@ class HTMLPurifier_Strategy_RemoveForeignElements extends HTMLPurifier_Strategy
$context->register('CurrentToken', $token); $context->register('CurrentToken', $token);
$e = false; $e = false;
if ($config->get('Core', 'CollectErrors')) { if ($config->get('Core.CollectErrors')) {
$e =& $context->get('ErrorCollector'); $e =& $context->get('ErrorCollector');
} }

View File

@ -52,7 +52,7 @@ class HTMLPurifier_URIDefinition extends HTMLPurifier_Definition
protected function setupFilters($config) { protected function setupFilters($config) {
foreach ($this->registeredFilters as $name => $filter) { foreach ($this->registeredFilters as $name => $filter) {
$conf = $config->get('URI', $name); $conf = $config->get('URI.' . $name);
if ($conf !== false && $conf !== null) { if ($conf !== false && $conf !== null) {
$this->addFilter($filter, $config); $this->addFilter($filter, $config);
} }
@ -61,15 +61,15 @@ class HTMLPurifier_URIDefinition extends HTMLPurifier_Definition
} }
protected function setupMemberVariables($config) { protected function setupMemberVariables($config) {
$this->host = $config->get('URI', 'Host'); $this->host = $config->get('URI.Host');
$base_uri = $config->get('URI', 'Base'); $base_uri = $config->get('URI.Base');
if (!is_null($base_uri)) { if (!is_null($base_uri)) {
$parser = new HTMLPurifier_URIParser(); $parser = new HTMLPurifier_URIParser();
$this->base = $parser->parse($base_uri); $this->base = $parser->parse($base_uri);
$this->defaultScheme = $this->base->scheme; $this->defaultScheme = $this->base->scheme;
if (is_null($this->host)) $this->host = $this->base->host; if (is_null($this->host)) $this->host = $this->base->host;
} }
if (is_null($this->defaultScheme)) $this->defaultScheme = $config->get('URI', 'DefaultScheme'); if (is_null($this->defaultScheme)) $this->defaultScheme = $config->get('URI.DefaultScheme');
} }
public function filter(&$uri, $config, $context) { public function filter(&$uri, $config, $context) {

View File

@ -5,7 +5,7 @@ class HTMLPurifier_URIFilter_HostBlacklist extends HTMLPurifier_URIFilter
public $name = 'HostBlacklist'; public $name = 'HostBlacklist';
protected $blacklist = array(); protected $blacklist = array();
public function prepare($config) { public function prepare($config) {
$this->blacklist = $config->get('URI', 'HostBlacklist'); $this->blacklist = $config->get('URI.HostBlacklist');
return true; return true;
} }
public function filter(&$uri, $config, $context) { public function filter(&$uri, $config, $context) {

View File

@ -9,10 +9,10 @@ class HTMLPurifier_URIFilter_Munge extends HTMLPurifier_URIFilter
protected $replace = array(); protected $replace = array();
public function prepare($config) { public function prepare($config) {
$this->target = $config->get('URI', $this->name); $this->target = $config->get('URI.' . $this->name);
$this->parser = new HTMLPurifier_URIParser(); $this->parser = new HTMLPurifier_URIParser();
$this->doEmbed = $config->get('URI', 'MungeResources'); $this->doEmbed = $config->get('URI.MungeResources');
$this->secretKey = $config->get('URI', 'MungeSecretKey'); $this->secretKey = $config->get('URI.MungeSecretKey');
return true; return true;
} }
public function filter(&$uri, $config, $context) { public function filter(&$uri, $config, $context) {

View File

@ -39,8 +39,8 @@ class HTMLPurifier_URISchemeRegistry
$null = null; // for the sake of passing by reference $null = null; // for the sake of passing by reference
// important, otherwise attacker could include arbitrary file // important, otherwise attacker could include arbitrary file
$allowed_schemes = $config->get('URI', 'AllowedSchemes'); $allowed_schemes = $config->get('URI.AllowedSchemes');
if (!$config->get('URI', 'OverrideAllowedSchemes') && if (!$config->get('URI.OverrideAllowedSchemes') &&
!isset($allowed_schemes[$scheme]) !isset($allowed_schemes[$scheme])
) { ) {
return $null; return $null;

View File

@ -0,0 +1,34 @@
#!/usr/bin/php
<?php
chdir(dirname(__FILE__));
require_once 'common.php';
assertCli();
/**
* @file
* Converts all instances of $config->set and $config->get to the new
* format, as described by docs/dev-config-bcbreaks.txt
*/
$FS = new FSTools();
chdir(dirname(__FILE__) . '/..');
$raw_files = $FS->globr('.', '*.php');
foreach ($raw_files as $file) {
$file = substr($file, 2); // rm leading './'
if (strpos($file, 'library/standalone/') === 0) continue;
if (strpos($file, 'maintenance/update-config.php') === 0) continue;
if (strpos($file, 'test-settings.php') === 0) continue;
if (substr_count($file, '.') > 1) continue; // rm meta files
// process the file
$contents = file_get_contents($file);
$contents = preg_replace(
"#config->(set|get)\('(.+?)', '(.+?)'#",
"config->\\1('\\2.\\3'",
$contents
);
if ($contents === '') continue;
file_put_contents($file, $contents);
}

View File

@ -274,7 +274,7 @@ function phorum_htmlpurifier_editor_after_subject() {
</p><?php </p><?php
$purifier =& HTMLPurifier::getInstance(); $purifier =& HTMLPurifier::getInstance();
$config = $purifier->config; $config = $purifier->config;
if ($config->get('AutoFormat', 'AutoParagraph')) { if ($config->get('AutoFormat.AutoParagraph')) {
?><p> ?><p>
<strong>Auto-paragraphing</strong> is enabled. Double <strong>Auto-paragraphing</strong> is enabled. Double
newlines will be converted to paragraphs; for single newlines will be converted to paragraphs; for single

View File

@ -42,7 +42,7 @@ $xml = simplexml_load_file('attrTransform.xml');
// attr transform enabled HTML Purifier // attr transform enabled HTML Purifier
$config = HTMLPurifier_Config::createDefault(); $config = HTMLPurifier_Config::createDefault();
$config->set('HTML', 'Doctype', 'XHTML 1.0 Strict'); $config->set('HTML.Doctype', 'XHTML 1.0 Strict');
$purifier = new HTMLPurifier($config); $purifier = new HTMLPurifier($config);
$title = isset($_GET['title']) ? $_GET['title'] : true; $title = isset($_GET['title']) ? $_GET['title'] : true;

View File

@ -50,8 +50,8 @@ if ($page) {
</div> </div>
<?php <?php
$config = HTMLPurifier_Config::createDefault(); $config = HTMLPurifier_Config::createDefault();
$config->set('Attr', 'EnableID', true); $config->set('Attr.EnableID', true);
$config->set('HTML', 'Strict', $strict); $config->set('HTML.Strict', $strict);
$purifier = new HTMLPurifier($config); $purifier = new HTMLPurifier($config);
echo $purifier->purify(file_get_contents("basic/$page.html")); echo $purifier->purify(file_get_contents("basic/$page.html"));
} else { } else {

View File

@ -52,7 +52,7 @@ $xml = simplexml_load_file('xssAttacks.xml');
// programatically disallow google.com for URI evasion tests // programatically disallow google.com for URI evasion tests
// not complete // not complete
$config = HTMLPurifier_Config::createDefault(); $config = HTMLPurifier_Config::createDefault();
$config->set('URI', 'HostBlacklist', array('google.com')); $config->set('URI.HostBlacklist', array('google.com'));
$purifier = new HTMLPurifier($config); $purifier = new HTMLPurifier($config);
?> ?>

View File

@ -116,7 +116,7 @@ class HTMLPurifier_AttrDef_CSSTest extends HTMLPurifier_AttrDefHarness
} }
function testProprietary() { function testProprietary() {
$this->config->set('CSS', 'Proprietary', true); $this->config->set('CSS.Proprietary', true);
$this->assertDef('scrollbar-arrow-color:#ff0;'); $this->assertDef('scrollbar-arrow-color:#ff0;');
$this->assertDef('scrollbar-base-color:#ff6347;'); $this->assertDef('scrollbar-base-color:#ff6347;');
@ -133,12 +133,12 @@ class HTMLPurifier_AttrDef_CSSTest extends HTMLPurifier_AttrDefHarness
} }
function testImportant() { function testImportant() {
$this->config->set('CSS', 'AllowImportant', true); $this->config->set('CSS.AllowImportant', true);
$this->assertDef('float:left !important;'); $this->assertDef('float:left !important;');
} }
function testTricky() { function testTricky() {
$this->config->set('CSS', 'AllowTricky', true); $this->config->set('CSS.AllowTricky', true);
$this->assertDef('display:none;'); $this->assertDef('display:none;');
$this->assertDef('visibility:visible;'); $this->assertDef('visibility:visible;');
$this->assertDef('overflow:scroll;'); $this->assertDef('overflow:scroll;');

View File

@ -16,7 +16,7 @@ class HTMLPurifier_AttrDef_HTML_FrameTargetTest extends HTMLPurifier_AttrDefHarn
} }
function test() { function test() {
$this->config->set('Attr', 'AllowedFrameTargets', 'foo,_blank'); $this->config->set('Attr.AllowedFrameTargets', 'foo,_blank');
$this->assertDef('', false); $this->assertDef('', false);
$this->assertDef('foo'); $this->assertDef('foo');
$this->assertDef('_blank'); $this->assertDef('_blank');

View File

@ -8,7 +8,7 @@ class HTMLPurifier_AttrDef_HTML_IDTest extends HTMLPurifier_AttrDefHarness
$id_accumulator = new HTMLPurifier_IDAccumulator(); $id_accumulator = new HTMLPurifier_IDAccumulator();
$this->context->register('IDAccumulator', $id_accumulator); $this->context->register('IDAccumulator', $id_accumulator);
$this->config->set('Attr', 'EnableID', true); $this->config->set('Attr.EnableID', true);
$this->def = new HTMLPurifier_AttrDef_HTML_ID(); $this->def = new HTMLPurifier_AttrDef_HTML_ID();
} }
@ -37,7 +37,7 @@ class HTMLPurifier_AttrDef_HTML_IDTest extends HTMLPurifier_AttrDefHarness
function testPrefix() { function testPrefix() {
$this->config->set('Attr', 'IDPrefix', 'user_'); $this->config->set('Attr.IDPrefix', 'user_');
$this->assertDef('alpha', 'user_alpha'); $this->assertDef('alpha', 'user_alpha');
$this->assertDef('<asa', false); $this->assertDef('<asa', false);
@ -52,8 +52,8 @@ class HTMLPurifier_AttrDef_HTML_IDTest extends HTMLPurifier_AttrDefHarness
function testTwoPrefixes() { function testTwoPrefixes() {
$this->config->set('Attr', 'IDPrefix', 'user_'); $this->config->set('Attr.IDPrefix', 'user_');
$this->config->set('Attr', 'IDPrefixLocal', 'story95_'); $this->config->set('Attr.IDPrefixLocal', 'story95_');
$this->assertDef('alpha', 'user_story95_alpha'); $this->assertDef('alpha', 'user_story95_alpha');
$this->assertDef('<asa', false); $this->assertDef('<asa', false);
@ -66,8 +66,8 @@ class HTMLPurifier_AttrDef_HTML_IDTest extends HTMLPurifier_AttrDefHarness
function testLocalPrefixWithoutMainPrefix() { function testLocalPrefixWithoutMainPrefix() {
// no effect when IDPrefix isn't set // no effect when IDPrefix isn't set
$this->config->set('Attr', 'IDPrefix', ''); $this->config->set('Attr.IDPrefix', '');
$this->config->set('Attr', 'IDPrefixLocal', 'story95_'); $this->config->set('Attr.IDPrefixLocal', 'story95_');
$this->expectError('%Attr.IDPrefixLocal cannot be used unless '. $this->expectError('%Attr.IDPrefixLocal cannot be used unless '.
'%Attr.IDPrefix is set'); '%Attr.IDPrefix is set');
$this->assertDef('amherst'); $this->assertDef('amherst');
@ -96,7 +96,7 @@ class HTMLPurifier_AttrDef_HTML_IDTest extends HTMLPurifier_AttrDefHarness
function testRegexp() { function testRegexp() {
$this->config->set('Attr', 'IDBlacklistRegexp', '/^g_/'); $this->config->set('Attr.IDBlacklistRegexp', '/^g_/');
$this->assertDef('good_id'); $this->assertDef('good_id');
$this->assertDef('g_bad_id', false); $this->assertDef('g_bad_id', false);

View File

@ -6,7 +6,7 @@ class HTMLPurifier_AttrDef_HTML_LinkTypesTest extends HTMLPurifier_AttrDefHarnes
function testNull() { function testNull() {
$this->def = new HTMLPurifier_AttrDef_HTML_LinkTypes('rel'); $this->def = new HTMLPurifier_AttrDef_HTML_LinkTypes('rel');
$this->config->set('Attr', 'AllowedRel', array('nofollow', 'foo')); $this->config->set('Attr.AllowedRel', array('nofollow', 'foo'));
$this->assertDef('', false); $this->assertDef('', false);
$this->assertDef('nofollow', true); $this->assertDef('nofollow', true);

View File

@ -49,7 +49,7 @@ class HTMLPurifier_AttrDef_URITest extends HTMLPurifier_AttrDefHarness
} }
function testConfigMunge() { function testConfigMunge() {
$this->config->set('URI', 'Munge', 'http://www.google.com/url?q=%s'); $this->config->set('URI.Munge', 'http://www.google.com/url?q=%s');
$this->assertDef( $this->assertDef(
'http://www.example.com/', 'http://www.example.com/',
'http://www.google.com/url?q=http%3A%2F%2Fwww.example.com%2F' 'http://www.google.com/url?q=http%3A%2F%2Fwww.example.com%2F'
@ -77,7 +77,7 @@ class HTMLPurifier_AttrDef_URITest extends HTMLPurifier_AttrDefHarness
function testURIDefinitionValidation() { function testURIDefinitionValidation() {
$parser = new HTMLPurifier_URIParser(); $parser = new HTMLPurifier_URIParser();
$uri = $parser->parse('http://example.com'); $uri = $parser->parse('http://example.com');
$this->config->set('URI', 'DefinitionID', 'HTMLPurifier_AttrDef_URITest->testURIDefinitionValidation'); $this->config->set('URI.DefinitionID', 'HTMLPurifier_AttrDef_URITest->testURIDefinitionValidation');
generate_mock_once('HTMLPurifier_URIDefinition'); generate_mock_once('HTMLPurifier_URIDefinition');
$uri_def = new HTMLPurifier_URIDefinitionMock(); $uri_def = new HTMLPurifier_URIDefinitionMock();
@ -121,8 +121,8 @@ class HTMLPurifier_AttrDef_URITest extends HTMLPurifier_AttrDefHarness
/* /*
function test_validate_configWhitelist() { function test_validate_configWhitelist() {
$this->config->set('URI', 'HostPolicy', 'DenyAll'); $this->config->set('URI.HostPolicy', 'DenyAll');
$this->config->set('URI', 'HostWhitelist', array(null, 'google.com')); $this->config->set('URI.HostWhitelist', array(null, 'google.com'));
$this->assertDef('http://example.com/fo/google.com', false); $this->assertDef('http://example.com/fo/google.com', false);
$this->assertDef('server.txt'); $this->assertDef('server.txt');

View File

@ -17,7 +17,7 @@ class HTMLPurifier_AttrTransform_BdoDirTest extends HTMLPurifier_AttrTransformHa
} }
function testAlternateDefault() { function testAlternateDefault() {
$this->config->set('Attr', 'DefaultTextDir', 'rtl'); $this->config->set('Attr.DefaultTextDir', 'rtl');
$this->assertResult( $this->assertResult(
array(), array(),
array('dir' => 'rtl') array('dir' => 'rtl')

View File

@ -9,7 +9,7 @@ class HTMLPurifier_AttrTransform_ImgRequiredTest extends HTMLPurifier_AttrTransf
} }
function testAddMissingAttr() { function testAddMissingAttr() {
$this->config->set('Core', 'RemoveInvalidImg', false); $this->config->set('Core.RemoveInvalidImg', false);
$this->assertResult( $this->assertResult(
array(), array(),
array('src' => '', 'alt' => 'Invalid image') array('src' => '', 'alt' => 'Invalid image')
@ -17,10 +17,10 @@ class HTMLPurifier_AttrTransform_ImgRequiredTest extends HTMLPurifier_AttrTransf
} }
function testAlternateDefaults() { function testAlternateDefaults() {
$this->config->set('Attr', 'DefaultInvalidImage', 'blank.png'); $this->config->set('Attr.DefaultInvalidImage', 'blank.png');
$this->config->set('Attr', 'DefaultInvalidImageAlt', 'Pawned!'); $this->config->set('Attr.DefaultInvalidImageAlt', 'Pawned!');
$this->config->set('Attr', 'DefaultImageAlt', 'not pawned'); $this->config->set('Attr.DefaultImageAlt', 'not pawned');
$this->config->set('Core', 'RemoveInvalidImg', false); $this->config->set('Core.RemoveInvalidImg', false);
$this->assertResult( $this->assertResult(
array(), array(),
array('src' => 'blank.png', 'alt' => 'Pawned!') array('src' => 'blank.png', 'alt' => 'Pawned!')
@ -35,7 +35,7 @@ class HTMLPurifier_AttrTransform_ImgRequiredTest extends HTMLPurifier_AttrTransf
} }
function testAddDefaultSrc() { function testAddDefaultSrc() {
$this->config->set('Core', 'RemoveInvalidImg', false); $this->config->set('Core.RemoveInvalidImg', false);
$this->assertResult( $this->assertResult(
array('alt' => 'intrigue'), array('alt' => 'intrigue'),
array('alt' => 'intrigue', 'src' => '') array('alt' => 'intrigue', 'src' => '')
@ -43,7 +43,7 @@ class HTMLPurifier_AttrTransform_ImgRequiredTest extends HTMLPurifier_AttrTransf
} }
function testAddDefaultAlt() { function testAddDefaultAlt() {
$this->config->set('Attr', 'DefaultImageAlt', 'default'); $this->config->set('Attr.DefaultImageAlt', 'default');
$this->assertResult( $this->assertResult(
array('src' => ''), array('src' => ''),
array('src' => '', 'alt' => 'default') array('src' => '', 'alt' => 'default')

View File

@ -18,7 +18,7 @@ class HTMLPurifier_AttrValidator_ErrorsTest extends HTMLPurifier_ErrorsHarness
} }
function testAttributesTransformedGlobalPre() { function testAttributesTransformedGlobalPre() {
$this->config->set('HTML', 'DefinitionID', $this->config->set('HTML.DefinitionID',
'HTMLPurifier_AttrValidator_ErrorsTest::testAttributesTransformedGlobalPre'); 'HTMLPurifier_AttrValidator_ErrorsTest::testAttributesTransformedGlobalPre');
$def = $this->config->getHTMLDefinition(true); $def = $this->config->getHTMLDefinition(true);
generate_mock_once('HTMLPurifier_AttrTransform'); generate_mock_once('HTMLPurifier_AttrTransform');
@ -39,7 +39,7 @@ class HTMLPurifier_AttrValidator_ErrorsTest extends HTMLPurifier_ErrorsHarness
} }
function testAttributesTransformedLocalPre() { function testAttributesTransformedLocalPre() {
$this->config->set('HTML', 'TidyLevel', 'heavy'); $this->config->set('HTML.TidyLevel', 'heavy');
$input = array('align' => 'right'); $input = array('align' => 'right');
$output = array('style' => 'text-align:right;'); $output = array('style' => 'text-align:right;');
$token = new HTMLPurifier_Token_Start('p', $input, 1); $token = new HTMLPurifier_Token_Start('p', $input, 1);

View File

@ -62,7 +62,7 @@ class HTMLPurifier_ChildDef_RequiredTest extends HTMLPurifier_ChildDefHarness
function testPCDATAAllowedWithEscaping() { function testPCDATAAllowedWithEscaping() {
$this->obj = new HTMLPurifier_ChildDef_Required('#PCDATA | b'); $this->obj = new HTMLPurifier_ChildDef_Required('#PCDATA | b');
$this->config->set('Core', 'EscapeInvalidChildren', true); $this->config->set('Core.EscapeInvalidChildren', true);
$this->assertResult( $this->assertResult(
'Out <b>Bold text</b><img />', 'Out <b>Bold text</b><img />',
'Out <b>Bold text</b>&lt;img /&gt;' 'Out <b>Bold text</b>&lt;img /&gt;'

View File

@ -65,7 +65,7 @@ extends HTMLPurifier_ChildDefHarness
} }
function testAlternateWrapper() { function testAlternateWrapper() {
$this->config->set('HTML', 'BlockWrapper', 'div'); $this->config->set('HTML.BlockWrapper', 'div');
$this->assertResult('Needs wrap', '<div>Needs wrap</div>'); $this->assertResult('Needs wrap', '<div>Needs wrap</div>');
} }
@ -73,8 +73,8 @@ extends HTMLPurifier_ChildDefHarness
function testError() { function testError() {
$this->expectError('Cannot use non-block element as block wrapper'); $this->expectError('Cannot use non-block element as block wrapper');
$this->obj = new HTMLPurifier_ChildDef_StrictBlockquote('div | p'); $this->obj = new HTMLPurifier_ChildDef_StrictBlockquote('div | p');
$this->config->set('HTML', 'BlockWrapper', 'dav'); $this->config->set('HTML.BlockWrapper', 'dav');
$this->config->set('Cache', 'DefinitionImpl', null); $this->config->set('Cache.DefinitionImpl', null);
$this->assertResult('Needs wrap', '<p>Needs wrap</p>'); $this->assertResult('Needs wrap', '<p>Needs wrap</p>');
} }

View File

@ -43,12 +43,12 @@ class HTMLPurifier_ChildDef_TableTest extends HTMLPurifier_ChildDefHarness
} }
function testStickyWhitespaceOnTr() { function testStickyWhitespaceOnTr() {
$this->config->set('Output', 'Newline', "\n"); $this->config->set('Output.Newline', "\n");
$this->assertResult("\n <tr />\n <tr />\n "); $this->assertResult("\n <tr />\n <tr />\n ");
} }
function testStickyWhitespaceOnTSection() { function testStickyWhitespaceOnTSection() {
$this->config->set('Output', 'Newline', "\n"); $this->config->set('Output.Newline', "\n");
$this->assertResult( $this->assertResult(
"\n\t<tbody />\n\t\t<tfoot />\n\t\t\t", "\n\t<tbody />\n\t\t<tfoot />\n\t\t\t",
"\n\t\t<tfoot />\n\t<tbody />\n\t\t\t" "\n\t\t<tfoot />\n\t<tbody />\n\t\t\t"

View File

@ -25,48 +25,49 @@ class HTMLPurifier_ConfigTest extends HTMLPurifier_Harness
$config = new HTMLPurifier_Config($this->schema); $config = new HTMLPurifier_Config($this->schema);
$config->autoFinalize = false; $config->autoFinalize = false;
$config->chatty = false;
// test default value retrieval // test default value retrieval
$this->assertIdentical($config->get('Element', 'Abbr'), 'H'); $this->assertIdentical($config->get('Element.Abbr'), 'H');
$this->assertIdentical($config->get('Element', 'Name'), 'hydrogen'); $this->assertIdentical($config->get('Element.Name'), 'hydrogen');
$this->assertIdentical($config->get('Element', 'Number'), 1); $this->assertIdentical($config->get('Element.Number'), 1);
$this->assertIdentical($config->get('Element', 'Mass'), 1.00794); $this->assertIdentical($config->get('Element.Mass'), 1.00794);
$this->assertIdentical($config->get('Element', 'Radioactive'), false); $this->assertIdentical($config->get('Element.Radioactive'), false);
$this->assertIdentical($config->get('Element', 'Isotopes'), array(1 => true, 2 => true, 3 => true)); $this->assertIdentical($config->get('Element.Isotopes'), array(1 => true, 2 => true, 3 => true));
$this->assertIdentical($config->get('Element', 'Traits'), array('nonmetallic', 'odorless', 'flammable')); $this->assertIdentical($config->get('Element.Traits'), array('nonmetallic', 'odorless', 'flammable'));
$this->assertIdentical($config->get('Element', 'IsotopeNames'), array(1 => 'protium', 2 => 'deuterium', 3 => 'tritium')); $this->assertIdentical($config->get('Element.IsotopeNames'), array(1 => 'protium', 2 => 'deuterium', 3 => 'tritium'));
$this->assertIdentical($config->get('Element', 'Object'), new stdClass()); $this->assertIdentical($config->get('Element.Object'), new stdClass());
// test setting values // test setting values
$config->set('Element', 'Abbr', 'Pu'); $config->set('Element.Abbr', 'Pu');
$config->set('Element', 'Name', 'PLUTONIUM'); // test decaps $config->set('Element.Name', 'PLUTONIUM'); // test decaps
$config->set('Element', 'Number', '94'); // test parsing $config->set('Element.Number', '94'); // test parsing
$config->set('Element', 'Mass', '244.'); // test parsing $config->set('Element.Mass', '244.'); // test parsing
$config->set('Element', 'Radioactive', true); $config->set('Element.Radioactive', true);
$config->set('Element', 'Isotopes', array(238, 239)); // test inversion $config->set('Element.Isotopes', array(238, 239)); // test inversion
$config->set('Element', 'Traits', 'nuclear, heavy, actinide'); // test parsing $config->set('Element.Traits', 'nuclear, heavy, actinide'); // test parsing
$config->set('Element', 'IsotopeNames', array(238 => 'Plutonium-238', 239 => 'Plutonium-239')); $config->set('Element.IsotopeNames', array(238 => 'Plutonium-238', 239 => 'Plutonium-239'));
$config->set('Element', 'Object', false); // unmodeled $config->set('Element.Object', false); // unmodeled
$this->expectError('Cannot set undefined directive Element.Metal to value'); $this->expectError('Cannot set undefined directive Element.Metal to value');
$config->set('Element', 'Metal', true); $config->set('Element.Metal', true);
$this->expectError('Value for Element.Radioactive is of invalid type, should be bool'); $this->expectError('Value for Element.Radioactive is of invalid type, should be bool');
$config->set('Element', 'Radioactive', 'very'); $config->set('Element.Radioactive', 'very');
// test value retrieval // test value retrieval
$this->assertIdentical($config->get('Element', 'Abbr'), 'Pu'); $this->assertIdentical($config->get('Element.Abbr'), 'Pu');
$this->assertIdentical($config->get('Element', 'Name'), 'plutonium'); $this->assertIdentical($config->get('Element.Name'), 'plutonium');
$this->assertIdentical($config->get('Element', 'Number'), 94); $this->assertIdentical($config->get('Element.Number'), 94);
$this->assertIdentical($config->get('Element', 'Mass'), 244.); $this->assertIdentical($config->get('Element.Mass'), 244.);
$this->assertIdentical($config->get('Element', 'Radioactive'), true); $this->assertIdentical($config->get('Element.Radioactive'), true);
$this->assertIdentical($config->get('Element', 'Isotopes'), array(238 => true, 239 => true)); $this->assertIdentical($config->get('Element.Isotopes'), array(238 => true, 239 => true));
$this->assertIdentical($config->get('Element', 'Traits'), array('nuclear', 'heavy', 'actinide')); $this->assertIdentical($config->get('Element.Traits'), array('nuclear', 'heavy', 'actinide'));
$this->assertIdentical($config->get('Element', 'IsotopeNames'), array(238 => 'Plutonium-238', 239 => 'Plutonium-239')); $this->assertIdentical($config->get('Element.IsotopeNames'), array(238 => 'Plutonium-238', 239 => 'Plutonium-239'));
$this->assertIdentical($config->get('Element', 'Object'), false); $this->assertIdentical($config->get('Element.Object'), false);
$this->expectError('Cannot retrieve value of undefined directive Element.Metal'); $this->expectError('Cannot retrieve value of undefined directive Element.Metal');
$config->get('Element', 'Metal'); $config->get('Element.Metal');
} }
@ -90,31 +91,32 @@ class HTMLPurifier_ConfigTest extends HTMLPurifier_Harness
$config = new HTMLPurifier_Config($this->schema); $config = new HTMLPurifier_Config($this->schema);
$config->autoFinalize = false; $config->autoFinalize = false;
$config->chatty = false;
// case sensitive // case sensitive
$config->set('Instrument', 'Manufacturer', 'Vandoren'); $config->set('Instrument.Manufacturer', 'Vandoren');
$this->assertIdentical($config->get('Instrument', 'Manufacturer'), 'Vandoren'); $this->assertIdentical($config->get('Instrument.Manufacturer'), 'Vandoren');
$config->set('Instrument', 'Manufacturer', 'Selmer'); $config->set('Instrument.Manufacturer', 'Selmer');
$this->assertIdentical($config->get('Instrument', 'Manufacturer'), 'Conn-Selmer'); $this->assertIdentical($config->get('Instrument.Manufacturer'), 'Conn-Selmer');
$this->expectError('Value not supported, valid values are: Yamaha, Conn-Selmer, Vandoren, Laubin, Buffet, other'); $this->expectError('Value not supported, valid values are: Yamaha, Conn-Selmer, Vandoren, Laubin, Buffet, other');
$config->set('Instrument', 'Manufacturer', 'buffet'); $config->set('Instrument.Manufacturer', 'buffet');
// case insensitive // case insensitive
$config->set('Instrument', 'Family', 'brass'); $config->set('Instrument.Family', 'brass');
$this->assertIdentical($config->get('Instrument', 'Family'), 'brass'); $this->assertIdentical($config->get('Instrument.Family'), 'brass');
$config->set('Instrument', 'Family', 'PERCUSSION'); $config->set('Instrument.Family', 'PERCUSSION');
$this->assertIdentical($config->get('Instrument', 'Family'), 'percussion'); $this->assertIdentical($config->get('Instrument.Family'), 'percussion');
$config->set('Instrument', 'Family', 'synth'); $config->set('Instrument.Family', 'synth');
$this->assertIdentical($config->get('Instrument', 'Family'), 'electronic'); $this->assertIdentical($config->get('Instrument.Family'), 'electronic');
$config->set('Instrument', 'Family', 'Synth'); $config->set('Instrument.Family', 'Synth');
$this->assertIdentical($config->get('Instrument', 'Family'), 'electronic'); $this->assertIdentical($config->get('Instrument.Family'), 'electronic');
} }
@ -125,16 +127,17 @@ class HTMLPurifier_ConfigTest extends HTMLPurifier_Harness
$config = new HTMLPurifier_Config($this->schema); $config = new HTMLPurifier_Config($this->schema);
$config->autoFinalize = false; $config->autoFinalize = false;
$config->chatty = false;
$config->set('ReportCard', 'English', 'B-'); $config->set('ReportCard.English', 'B-');
$this->assertIdentical($config->get('ReportCard', 'English'), 'B-'); $this->assertIdentical($config->get('ReportCard.English'), 'B-');
$config->set('ReportCard', 'English', null); // not yet graded $config->set('ReportCard.English', null); // not yet graded
$this->assertIdentical($config->get('ReportCard', 'English'), null); $this->assertIdentical($config->get('ReportCard.English'), null);
// error // error
$this->expectError('Value for ReportCard.Absences is of invalid type, should be int'); $this->expectError('Value for ReportCard.Absences is of invalid type, should be int');
$config->set('ReportCard', 'Absences', null); $config->set('ReportCard.Absences', null);
} }
@ -145,15 +148,16 @@ class HTMLPurifier_ConfigTest extends HTMLPurifier_Harness
$config = new HTMLPurifier_Config($this->schema); $config = new HTMLPurifier_Config($this->schema);
$config->autoFinalize = false; $config->autoFinalize = false;
$config->chatty = false;
$this->assertIdentical($config->get('Home', 'Rug'), 3); $this->assertIdentical($config->get('Home.Rug'), 3);
$this->expectError('Cannot get value from aliased directive, use real name Home.Rug'); $this->expectError('Cannot get value from aliased directive, use real name Home.Rug');
$config->get('Home', 'Carpet'); $config->get('Home.Carpet');
$this->expectError('Home.Carpet is an alias, preferred directive name is Home.Rug'); $this->expectError('Home.Carpet is an alias, preferred directive name is Home.Rug');
$config->set('Home', 'Carpet', 999); $config->set('Home.Carpet', 999);
$this->assertIdentical($config->get('Home', 'Rug'), 999); $this->assertIdentical($config->get('Home.Rug'), 999);
} }
@ -166,6 +170,7 @@ class HTMLPurifier_ConfigTest extends HTMLPurifier_Harness
$config = new HTMLPurifier_Config($this->schema); $config = new HTMLPurifier_Config($this->schema);
$config->autoFinalize = false; $config->autoFinalize = false;
$config->chatty = false;
// grab a namespace // grab a namespace
$this->assertIdentical( $this->assertIdentical(
@ -193,9 +198,9 @@ class HTMLPurifier_ConfigTest extends HTMLPurifier_Harness
$config->loadIni(dirname(__FILE__) . '/ConfigTest-loadIni.ini'); $config->loadIni(dirname(__FILE__) . '/ConfigTest-loadIni.ini');
$this->assertIdentical($config->get('Shortcut', 'Copy'), 'q'); $this->assertIdentical($config->get('Shortcut.Copy'), 'q');
$this->assertIdentical($config->get('Shortcut', 'Paste'), 'p'); $this->assertIdentical($config->get('Shortcut.Paste'), 'p');
$this->assertIdentical($config->get('Shortcut', 'Cut'), 't'); $this->assertIdentical($config->get('Shortcut.Cut'), 't');
} }
@ -205,7 +210,7 @@ class HTMLPurifier_ConfigTest extends HTMLPurifier_Harness
// generation routines have dependencies on configuration values // generation routines have dependencies on configuration values
$config = HTMLPurifier_Config::createDefault(); $config = HTMLPurifier_Config::createDefault();
$config->set('HTML', 'Doctype', 'XHTML 1.0 Strict'); $config->set('HTML.Doctype', 'XHTML 1.0 Strict');
$config->autoFinalize = false; $config->autoFinalize = false;
$def = $config->getCSSDefinition(); $def = $config->getCSSDefinition();
@ -219,15 +224,15 @@ class HTMLPurifier_ConfigTest extends HTMLPurifier_Harness
$old_def = clone $def2; $old_def = clone $def2;
$config->set('HTML', 'Doctype', 'HTML 4.01 Transitional'); $config->set('HTML.Doctype', 'HTML 4.01 Transitional');
$def = $config->getHTMLDefinition(); $def = $config->getHTMLDefinition();
$this->assertIsA($def, 'HTMLPurifier_HTMLDefinition'); $this->assertIsA($def, 'HTMLPurifier_HTMLDefinition');
$this->assertNotEqual($def, $old_def); $this->assertNotEqual($def, $old_def);
$this->assertTrue($def->setup); $this->assertTrue($def->setup);
// test retrieval of raw definition // test retrieval of raw definition
$config->set('HTML', 'DefinitionID', 'HTMLPurifier_ConfigTest->test_getHTMLDefinition()'); $config->set('HTML.DefinitionID', 'HTMLPurifier_ConfigTest->test_getHTMLDefinition()');
$config->set('HTML', 'DefinitionRev', 3); $config->set('HTML.DefinitionRev', 3);
$def = $config->getHTMLDefinition(true); $def = $config->getHTMLDefinition(true);
$this->assertNotEqual($def, $old_def); $this->assertNotEqual($def, $old_def);
$this->assertEqual(false, $def->setup); $this->assertEqual(false, $def->setup);
@ -268,10 +273,10 @@ class HTMLPurifier_ConfigTest extends HTMLPurifier_Harness
$config_loadabbr = new HTMLPurifier_Config($this->schema); $config_loadabbr = new HTMLPurifier_Config($this->schema);
$config_loadfull = new HTMLPurifier_Config($this->schema); $config_loadfull = new HTMLPurifier_Config($this->schema);
$config_manual->set('Zoo', 'Aadvark', 3); $config_manual->set('Zoo.Aadvark', 3);
$config_manual->set('Zoo', 'Boar', 5); $config_manual->set('Zoo.Boar', 5);
$config_manual->set('Zoo', 'Camel', 2000); // that's a lotta camels! $config_manual->set('Zoo.Camel', 2000); // that's a lotta camels!
$config_manual->set('Zoo', 'Others', array('Peacock', 'Dodo')); // wtf! $config_manual->set('Zoo.Others', array('Peacock', 'Dodo')); // wtf!
// condensed form // condensed form
$config_loadabbr->loadArray(array( $config_loadabbr->loadArray(array(
@ -302,7 +307,7 @@ class HTMLPurifier_ConfigTest extends HTMLPurifier_Harness
$this->schema->add('Cake.Flavor', 'vanilla', 'string', false); $this->schema->add('Cake.Flavor', 'vanilla', 'string', false);
$config = new HTMLPurifier_Config($this->schema); $config = new HTMLPurifier_Config($this->schema);
$config->set('Cake', 'Sprinkles', 42); $config->set('Cake.Sprinkles', 42);
// test flat pass-through // test flat pass-through
$created_config = HTMLPurifier_Config::create($config, $this->schema); $created_config = HTMLPurifier_Config::create($config, $this->schema);
@ -326,13 +331,14 @@ class HTMLPurifier_ConfigTest extends HTMLPurifier_Harness
$config = new HTMLPurifier_Config($this->schema); $config = new HTMLPurifier_Config($this->schema);
$config->autoFinalize = false; $config->autoFinalize = false;
$config->chatty = false;
$config->set('Poem', 'Meter', 'irregular'); $config->set('Poem.Meter', 'irregular');
$config->finalize(); $config->finalize();
$this->expectError('Cannot set directive after finalization'); $this->expectError('Cannot set directive after finalization');
$config->set('Poem', 'Meter', 'vedic'); $config->set('Poem.Meter', 'vedic');
$this->expectError('Cannot load directives after finalization'); $this->expectError('Cannot load directives after finalization');
$config->loadArray(array('Poem.Meter' => 'octosyllable')); $config->loadArray(array('Poem.Meter' => 'octosyllable'));
@ -422,6 +428,15 @@ class HTMLPurifier_ConfigTest extends HTMLPurifier_Harness
} }
function testDeprecatedAPI() {
$this->schema->add('Foo.Bar', 2, 'int', false);
$config = new HTMLPurifier_Config($this->schema);
$config->chatty = false;
$this->expectError('Using deprecated API: use $config->set(\'Foo.Bar\', ...) instead');
$config->set('Foo', 'Bar', 4);
$this->expectError('Using deprecated API: use $config->get(\'Foo.Bar\') instead');
$this->assertIdentical($config->get('Foo', 'Bar'), 4);
}
} }
// vim: et sw=4 sts=4 // vim: et sw=4 sts=4

View File

@ -8,7 +8,7 @@ class HTMLPurifier_DefinitionCache_SerializerTest extends HTMLPurifier_Definitio
$cache = new HTMLPurifier_DefinitionCache_Serializer('Test'); $cache = new HTMLPurifier_DefinitionCache_Serializer('Test');
$config = $this->generateConfigMock('serial'); $config = $this->generateConfigMock('serial');
$config->setReturnValue('get', 2, array('Test', 'DefinitionRev')); $config->setReturnValue('get', 2, array('Test.DefinitionRev'));
$config->version = '1.0.0'; $config->version = '1.0.0';
$config_md5 = '1.0.0,serial,2'; $config_md5 = '1.0.0,serial,2';
@ -116,12 +116,12 @@ class HTMLPurifier_DefinitionCache_SerializerTest extends HTMLPurifier_Definitio
$config1 = $this->generateConfigMock(); $config1 = $this->generateConfigMock();
$config1->version = '0.9.0'; $config1->version = '0.9.0';
$config1->setReturnValue('get', 574, array('Test', 'DefinitionRev')); $config1->setReturnValue('get', 574, array('Test.DefinitionRev'));
$def1 = $this->generateDefinition(array('info' => 1)); $def1 = $this->generateDefinition(array('info' => 1));
$config2 = $this->generateConfigMock(); $config2 = $this->generateConfigMock();
$config2->version = '1.0.0beta'; $config2->version = '1.0.0beta';
$config2->setReturnValue('get', 1, array('Test', 'DefinitionRev')); $config2->setReturnValue('get', 1, array('Test.DefinitionRev'));
$def2 = $this->generateDefinition(array('info' => 3)); $def2 = $this->generateDefinition(array('info' => 3));
$cache->set($def1, $config1); $cache->set($def1, $config1);
@ -140,12 +140,12 @@ class HTMLPurifier_DefinitionCache_SerializerTest extends HTMLPurifier_Definitio
$config1 = $this->generateConfigMock('serial1'); $config1 = $this->generateConfigMock('serial1');
$config1->version = '1.0.0'; $config1->version = '1.0.0';
$config1->setReturnValue('get', 1, array('Test', 'DefinitionRev')); $config1->setReturnValue('get', 1, array('Test.DefinitionRev'));
$def1 = $this->generateDefinition(array('info' => 1)); $def1 = $this->generateDefinition(array('info' => 1));
$config2 = $this->generateConfigMock('serial2'); $config2 = $this->generateConfigMock('serial2');
$config2->version = '1.0.0'; $config2->version = '1.0.0';
$config2->setReturnValue('get', 34, array('Test', 'DefinitionRev')); $config2->setReturnValue('get', 34, array('Test.DefinitionRev'));
$def2 = $this->generateDefinition(array('info' => 3)); $def2 = $this->generateDefinition(array('info' => 3));
$cache->set($def1, $config1); $cache->set($def1, $config1);
@ -180,9 +180,9 @@ class HTMLPurifier_DefinitionCache_SerializerTest extends HTMLPurifier_Definitio
$cache = new HTMLPurifier_DefinitionCache_Serializer('Test'); $cache = new HTMLPurifier_DefinitionCache_Serializer('Test');
$config = $this->generateConfigMock('serial'); $config = $this->generateConfigMock('serial');
$config->version = '1.0.0'; $config->version = '1.0.0';
$config->setReturnValue('get', 1, array('Test', 'DefinitionRev')); $config->setReturnValue('get', 1, array('Test.DefinitionRev'));
$dir = dirname(__FILE__) . '/SerializerTest'; $dir = dirname(__FILE__) . '/SerializerTest';
$config->setReturnValue('get', $dir, array('Cache', 'SerializerPath')); $config->setReturnValue('get', $dir, array('Cache.SerializerPath'));
$def_original = $this->generateDefinition(); $def_original = $this->generateDefinition();
$cache->add($def_original, $config); $cache->add($def_original, $config);

View File

@ -45,21 +45,21 @@ class HTMLPurifier_DefinitionCacheFactoryTest extends HTMLPurifier_Harness
} }
function test_create_invalid() { function test_create_invalid() {
$this->config->set('Cache', 'DefinitionImpl', 'Invalid'); $this->config->set('Cache.DefinitionImpl', 'Invalid');
$this->expectError('Unrecognized DefinitionCache Invalid, using Serializer instead'); $this->expectError('Unrecognized DefinitionCache Invalid, using Serializer instead');
$cache = $this->factory->create('Test', $this->config); $cache = $this->factory->create('Test', $this->config);
$this->assertIsA($cache, 'HTMLPurifier_DefinitionCache_Serializer'); $this->assertIsA($cache, 'HTMLPurifier_DefinitionCache_Serializer');
} }
function test_null() { function test_null() {
$this->config->set('Cache', 'DefinitionImpl', null); $this->config->set('Cache.DefinitionImpl', null);
$cache = $this->factory->create('Test', $this->config); $cache = $this->factory->create('Test', $this->config);
$this->assertEqual($cache, new HTMLPurifier_DefinitionCache_Null('Test')); $this->assertEqual($cache, new HTMLPurifier_DefinitionCache_Null('Test'));
} }
function test_register() { function test_register() {
generate_mock_once('HTMLPurifier_DefinitionCache'); generate_mock_once('HTMLPurifier_DefinitionCache');
$this->config->set('Cache', 'DefinitionImpl', 'TestCache'); $this->config->set('Cache.DefinitionImpl', 'TestCache');
$this->factory->register('TestCache', $class = 'HTMLPurifier_DefinitionCacheMock'); $this->factory->register('TestCache', $class = 'HTMLPurifier_DefinitionCacheMock');
$cache = $this->factory->create('Test', $this->config); $cache = $this->factory->create('Test', $this->config);
$this->assertIsA($cache, $class); $this->assertIsA($cache, $class);

View File

@ -10,7 +10,7 @@ class HTMLPurifier_DefinitionCacheTest extends HTMLPurifier_Harness
generate_mock_once('HTMLPurifier_Config'); generate_mock_once('HTMLPurifier_Config');
$config = new HTMLPurifier_ConfigMock(); $config = new HTMLPurifier_ConfigMock();
$config->version = '1.0.0'; // hopefully no conflicts $config->version = '1.0.0'; // hopefully no conflicts
$config->setReturnValue('get', 10, array('Test', 'DefinitionRev')); $config->setReturnValue('get', 10, array('Test.DefinitionRev'));
$config->setReturnValue('getBatchSerial', 'hash', array('Test')); $config->setReturnValue('getBatchSerial', 'hash', array('Test'));
$this->assertIdentical($cache->isOld('1.0.0,hash,10', $config), false); $this->assertIdentical($cache->isOld('1.0.0,hash,10', $config), false);

View File

@ -39,7 +39,7 @@ class HTMLPurifier_EncoderTest extends HTMLPurifier_Harness
} }
function test_convertToUTF8_spuriousEncoding() { function test_convertToUTF8_spuriousEncoding() {
$this->config->set('Core', 'Encoding', 'utf99'); $this->config->set('Core.Encoding', 'utf99');
$this->expectError('Invalid encoding utf99'); $this->expectError('Invalid encoding utf99');
$this->assertIdentical( $this->assertIdentical(
HTMLPurifier_Encoder::convertToUTF8("\xF6", $this->config, $this->context), HTMLPurifier_Encoder::convertToUTF8("\xF6", $this->config, $this->context),
@ -48,7 +48,7 @@ class HTMLPurifier_EncoderTest extends HTMLPurifier_Harness
} }
function test_convertToUTF8_iso8859_1() { function test_convertToUTF8_iso8859_1() {
$this->config->set('Core', 'Encoding', 'ISO-8859-1'); $this->config->set('Core.Encoding', 'ISO-8859-1');
$this->assertIdentical( $this->assertIdentical(
HTMLPurifier_Encoder::convertToUTF8("\xF6", $this->config, $this->context), HTMLPurifier_Encoder::convertToUTF8("\xF6", $this->config, $this->context),
"\xC3\xB6" "\xC3\xB6"
@ -56,8 +56,8 @@ class HTMLPurifier_EncoderTest extends HTMLPurifier_Harness
} }
function test_convertToUTF8_withoutIconv() { function test_convertToUTF8_withoutIconv() {
$this->config->set('Core', 'Encoding', 'ISO-8859-1'); $this->config->set('Core.Encoding', 'ISO-8859-1');
$this->config->set('Test', 'ForceNoIconv', true); $this->config->set('Test.ForceNoIconv', true);
$this->assertIdentical( $this->assertIdentical(
HTMLPurifier_Encoder::convertToUTF8("\xF6", $this->config, $this->context), HTMLPurifier_Encoder::convertToUTF8("\xF6", $this->config, $this->context),
"\xC3\xB6" "\xC3\xB6"
@ -78,7 +78,7 @@ class HTMLPurifier_EncoderTest extends HTMLPurifier_Harness
} }
function test_convertFromUTF8_iso8859_1() { function test_convertFromUTF8_iso8859_1() {
$this->config->set('Core', 'Encoding', 'ISO-8859-1'); $this->config->set('Core.Encoding', 'ISO-8859-1');
$this->assertIdentical( $this->assertIdentical(
HTMLPurifier_Encoder::convertFromUTF8("\xC3\xB6", $this->config, $this->context), HTMLPurifier_Encoder::convertFromUTF8("\xC3\xB6", $this->config, $this->context),
"\xF6", "\xF6",
@ -88,7 +88,7 @@ class HTMLPurifier_EncoderTest extends HTMLPurifier_Harness
function test_convertFromUTF8_iconvNoChars() { function test_convertFromUTF8_iconvNoChars() {
if (!function_exists('iconv')) return; if (!function_exists('iconv')) return;
$this->config->set('Core', 'Encoding', 'ISO-8859-1'); $this->config->set('Core.Encoding', 'ISO-8859-1');
$this->assertIdentical( $this->assertIdentical(
HTMLPurifier_Encoder::convertFromUTF8($this->getZhongWen(), $this->config, $this->context), HTMLPurifier_Encoder::convertFromUTF8($this->getZhongWen(), $this->config, $this->context),
" (Chinese)" " (Chinese)"
@ -97,8 +97,8 @@ class HTMLPurifier_EncoderTest extends HTMLPurifier_Harness
function test_convertFromUTF8_phpNormal() { function test_convertFromUTF8_phpNormal() {
// Plain PHP implementation has slightly different behavior // Plain PHP implementation has slightly different behavior
$this->config->set('Core', 'Encoding', 'ISO-8859-1'); $this->config->set('Core.Encoding', 'ISO-8859-1');
$this->config->set('Test', 'ForceNoIconv', true); $this->config->set('Test.ForceNoIconv', true);
$this->assertIdentical( $this->assertIdentical(
HTMLPurifier_Encoder::convertFromUTF8("\xC3\xB6", $this->config, $this->context), HTMLPurifier_Encoder::convertFromUTF8("\xC3\xB6", $this->config, $this->context),
"\xF6", "\xF6",
@ -107,8 +107,8 @@ class HTMLPurifier_EncoderTest extends HTMLPurifier_Harness
} }
function test_convertFromUTF8_phpNoChars() { function test_convertFromUTF8_phpNoChars() {
$this->config->set('Core', 'Encoding', 'ISO-8859-1'); $this->config->set('Core.Encoding', 'ISO-8859-1');
$this->config->set('Test', 'ForceNoIconv', true); $this->config->set('Test.ForceNoIconv', true);
$this->assertIdentical( $this->assertIdentical(
HTMLPurifier_Encoder::convertFromUTF8($this->getZhongWen(), $this->config, $this->context), HTMLPurifier_Encoder::convertFromUTF8($this->getZhongWen(), $this->config, $this->context),
"?? (Chinese)" "?? (Chinese)"
@ -117,8 +117,8 @@ class HTMLPurifier_EncoderTest extends HTMLPurifier_Harness
function test_convertFromUTF8_withProtection() { function test_convertFromUTF8_withProtection() {
// Preserve the characters! // Preserve the characters!
$this->config->set('Core', 'Encoding', 'ISO-8859-1'); $this->config->set('Core.Encoding', 'ISO-8859-1');
$this->config->set('Core', 'EscapeNonASCIICharacters', true); $this->config->set('Core.EscapeNonASCIICharacters', true);
$this->assertIdentical( $this->assertIdentical(
HTMLPurifier_Encoder::convertFromUTF8($this->getZhongWen(), $this->config, $this->context), HTMLPurifier_Encoder::convertFromUTF8($this->getZhongWen(), $this->config, $this->context),
"&#20013;&#25991; (Chinese)" "&#20013;&#25991; (Chinese)"
@ -169,7 +169,7 @@ class HTMLPurifier_EncoderTest extends HTMLPurifier_Harness
function testShiftJIS() { function testShiftJIS() {
if (!function_exists('iconv')) return; if (!function_exists('iconv')) return;
$this->config->set('Core', 'Encoding', 'Shift_JIS'); $this->config->set('Core.Encoding', 'Shift_JIS');
// This actually looks like a Yen, but we're going to treat it differently // This actually looks like a Yen, but we're going to treat it differently
$this->assertIdentical( $this->assertIdentical(
HTMLPurifier_Encoder::convertFromUTF8('\\~', $this->config, $this->context), HTMLPurifier_Encoder::convertFromUTF8('\\~', $this->config, $this->context),

View File

@ -8,7 +8,7 @@ class HTMLPurifier_Filter_ExtractStyleBlocksTest extends HTMLPurifier_Harness
// usual use case: // usual use case:
function test_tokenizeHTML_extractStyleBlocks() { function test_tokenizeHTML_extractStyleBlocks() {
$this->config->set('Filter', 'ExtractStyleBlocks', true); $this->config->set('Filter.ExtractStyleBlocks', true);
$purifier = new HTMLPurifier($this->config); $purifier = new HTMLPurifier($this->config);
$result = $purifier->purify('<style type="text/css">.foo {text-align:center;bogus:remove-me;}</style>Test<style>* {font-size:12pt;}</style>'); $result = $purifier->purify('<style type="text/css">.foo {text-align:center;bogus:remove-me;}</style>Test<style>* {font-size:12pt;}</style>');
$this->assertIdentical($result, 'Test'); $this->assertIdentical($result, 'Test');
@ -23,7 +23,7 @@ class HTMLPurifier_Filter_ExtractStyleBlocksTest extends HTMLPurifier_Harness
function assertExtractStyleBlocks($html, $expect = true, $styles = array()) { function assertExtractStyleBlocks($html, $expect = true, $styles = array()) {
$filter = new HTMLPurifier_Filter_ExtractStyleBlocks(); // disable cleaning $filter = new HTMLPurifier_Filter_ExtractStyleBlocks(); // disable cleaning
if ($expect === true) $expect = $html; if ($expect === true) $expect = $html;
$this->config->set('FilterParam', 'ExtractStyleBlocksTidyImpl', false); $this->config->set('FilterParam.ExtractStyleBlocksTidyImpl', false);
$result = $filter->preFilter($html, $this->config, $this->context); $result = $filter->preFilter($html, $this->config, $this->context);
$this->assertIdentical($result, $expect); $this->assertIdentical($result, $expect);
$this->assertIdentical($this->context->get('StyleBlocks'), $styles); $this->assertIdentical($this->context->get('StyleBlocks'), $styles);
@ -104,14 +104,14 @@ class HTMLPurifier_Filter_ExtractStyleBlocksTest extends HTMLPurifier_Harness
} }
function test_cleanCSS_noEscapeCodes() { function test_cleanCSS_noEscapeCodes() {
$this->config->set('FilterParam', 'ExtractStyleBlocksEscaping', false); $this->config->set('FilterParam.ExtractStyleBlocksEscaping', false);
$this->assertCleanCSS( $this->assertCleanCSS(
".class {\nfont-family:'</style>';\n}" ".class {\nfont-family:'</style>';\n}"
); );
} }
function test_cleanCSS_scope() { function test_cleanCSS_scope() {
$this->config->set('FilterParam', 'ExtractStyleBlocksScope', '#foo'); $this->config->set('FilterParam.ExtractStyleBlocksScope', '#foo');
$this->assertCleanCSS( $this->assertCleanCSS(
"p {\ntext-indent:1em;\n}", "p {\ntext-indent:1em;\n}",
"#foo p {\ntext-indent:1em;\n}" "#foo p {\ntext-indent:1em;\n}"
@ -119,7 +119,7 @@ class HTMLPurifier_Filter_ExtractStyleBlocksTest extends HTMLPurifier_Harness
} }
function test_cleanCSS_scopeWithSelectorCommas() { function test_cleanCSS_scopeWithSelectorCommas() {
$this->config->set('FilterParam', 'ExtractStyleBlocksScope', '#foo'); $this->config->set('FilterParam.ExtractStyleBlocksScope', '#foo');
$this->assertCleanCSS( $this->assertCleanCSS(
"b, i {\ntext-decoration:underline;\n}", "b, i {\ntext-decoration:underline;\n}",
"#foo b, #foo i {\ntext-decoration:underline;\n}" "#foo b, #foo i {\ntext-decoration:underline;\n}"
@ -127,17 +127,17 @@ class HTMLPurifier_Filter_ExtractStyleBlocksTest extends HTMLPurifier_Harness
} }
function test_cleanCSS_scopeWithNaughtySelector() { function test_cleanCSS_scopeWithNaughtySelector() {
$this->config->set('FilterParam', 'ExtractStyleBlocksScope', '#foo'); $this->config->set('FilterParam.ExtractStyleBlocksScope', '#foo');
$this->assertCleanCSS(" + p {\ntext-indent:1em;\n}", ''); $this->assertCleanCSS(" + p {\ntext-indent:1em;\n}", '');
} }
function test_cleanCSS_scopeWithMultipleNaughtySelectors() { function test_cleanCSS_scopeWithMultipleNaughtySelectors() {
$this->config->set('FilterParam', 'ExtractStyleBlocksScope', '#foo'); $this->config->set('FilterParam.ExtractStyleBlocksScope', '#foo');
$this->assertCleanCSS(" ++ ++ p {\ntext-indent:1em;\n}", ''); $this->assertCleanCSS(" ++ ++ p {\ntext-indent:1em;\n}", '');
} }
function test_cleanCSS_scopeWithCommas() { function test_cleanCSS_scopeWithCommas() {
$this->config->set('FilterParam', 'ExtractStyleBlocksScope', '#foo, .bar'); $this->config->set('FilterParam.ExtractStyleBlocksScope', '#foo, .bar');
$this->assertCleanCSS( $this->assertCleanCSS(
"p {\ntext-indent:1em;\n}", "p {\ntext-indent:1em;\n}",
"#foo p, .bar p {\ntext-indent:1em;\n}" "#foo p, .bar p {\ntext-indent:1em;\n}"
@ -145,7 +145,7 @@ class HTMLPurifier_Filter_ExtractStyleBlocksTest extends HTMLPurifier_Harness
} }
function test_cleanCSS_scopeAllWithCommas() { function test_cleanCSS_scopeAllWithCommas() {
$this->config->set('FilterParam', 'ExtractStyleBlocksScope', '#foo, .bar'); $this->config->set('FilterParam.ExtractStyleBlocksScope', '#foo, .bar');
$this->assertCleanCSS( $this->assertCleanCSS(
"p, div {\ntext-indent:1em;\n}", "p, div {\ntext-indent:1em;\n}",
"#foo p, #foo div, .bar p, .bar div {\ntext-indent:1em;\n}" "#foo p, #foo div, .bar p, .bar div {\ntext-indent:1em;\n}"
@ -153,7 +153,7 @@ class HTMLPurifier_Filter_ExtractStyleBlocksTest extends HTMLPurifier_Harness
} }
function test_cleanCSS_scopeWithConflicts() { function test_cleanCSS_scopeWithConflicts() {
$this->config->set('FilterParam', 'ExtractStyleBlocksScope', 'p'); $this->config->set('FilterParam.ExtractStyleBlocksScope', 'p');
$this->assertCleanCSS( $this->assertCleanCSS(
"div { "div {
text-align:right; text-align:right;

View File

@ -15,7 +15,7 @@ class HTMLPurifier_GeneratorTest extends HTMLPurifier_Harness
public function setUp() { public function setUp() {
parent::setUp(); parent::setUp();
$this->config->set('Output', 'Newline', "\n"); $this->config->set('Output.Newline', "\n");
} }
/** /**
@ -138,7 +138,7 @@ class HTMLPurifier_GeneratorTest extends HTMLPurifier_Harness
function test_generateAttributes_minimized() { function test_generateAttributes_minimized() {
$this->config->set('HTML', 'Doctype', 'HTML 4.01 Transitional'); $this->config->set('HTML.Doctype', 'HTML 4.01 Transitional');
$this->assertGenerateAttributes( $this->assertGenerateAttributes(
array('compact' => 'compact'), 'compact', 'menu' array('compact' => 'compact'), 'compact', 'menu'
); );
@ -197,7 +197,7 @@ class HTMLPurifier_GeneratorTest extends HTMLPurifier_Harness
} }
function test_generateFromTokens_Scripting_disableWrapper() { function test_generateFromTokens_Scripting_disableWrapper() {
$this->config->set('Output', 'CommentScriptContents', false); $this->config->set('Output.CommentScriptContents', false);
$this->assertGeneration( $this->assertGeneration(
array( array(
new HTMLPurifier_Token_Start('script'), new HTMLPurifier_Token_Start('script'),
@ -209,7 +209,7 @@ class HTMLPurifier_GeneratorTest extends HTMLPurifier_Harness
} }
function test_generateFromTokens_XHTMLoff() { function test_generateFromTokens_XHTMLoff() {
$this->config->set('HTML', 'XHTML', false); $this->config->set('HTML.XHTML', false);
// omit trailing slash // omit trailing slash
$this->assertGeneration( $this->assertGeneration(
@ -236,8 +236,8 @@ class HTMLPurifier_GeneratorTest extends HTMLPurifier_Harness
// just don't test; Tidy is exploding on me. // just don't test; Tidy is exploding on me.
return; return;
$this->config->set('Core', 'TidyFormat', true); $this->config->set('Core.TidyFormat', true);
$this->config->set('Output', 'Newline', "\n"); $this->config->set('Output.Newline', "\n");
// nice wrapping please // nice wrapping please
$this->assertGeneration( $this->assertGeneration(
@ -252,7 +252,7 @@ class HTMLPurifier_GeneratorTest extends HTMLPurifier_Harness
} }
function test_generateFromTokens_sortAttr() { function test_generateFromTokens_sortAttr() {
$this->config->set('Output', 'SortAttr', true); $this->config->set('Output.SortAttr', true);
$this->assertGeneration( $this->assertGeneration(
array( new HTMLPurifier_Token_Start('p', array('b'=>'c', 'a'=>'d')) ), array( new HTMLPurifier_Token_Start('p', array('b'=>'c', 'a'=>'d')) ),

View File

@ -6,7 +6,7 @@ class HTMLPurifier_HTMLDefinitionTest extends HTMLPurifier_Harness
function expectError($error = false, $message = '%s') { function expectError($error = false, $message = '%s') {
// Because we're testing a definition, it's vital that the cache // Because we're testing a definition, it's vital that the cache
// is turned off for tests that expect errors. // is turned off for tests that expect errors.
$this->config->set('Cache', 'DefinitionImpl', null); $this->config->set('Cache.DefinitionImpl', null);
parent::expectError($error); parent::expectError($error);
} }
@ -87,29 +87,29 @@ a[href|title]
} }
function test_AllowedElements() { function test_AllowedElements() {
$this->config->set('HTML', 'AllowedElements', 'p'); $this->config->set('HTML.AllowedElements', 'p');
$this->assertPurification_AllowedElements_p(); $this->assertPurification_AllowedElements_p();
} }
function test_AllowedElements_multiple() { function test_AllowedElements_multiple() {
$this->config->set('HTML', 'AllowedElements', 'p,div'); $this->config->set('HTML.AllowedElements', 'p,div');
$this->assertPurification('<div><p><b>Jelly</b></p></div>', '<div><p>Jelly</p></div>'); $this->assertPurification('<div><p><b>Jelly</b></p></div>', '<div><p>Jelly</p></div>');
} }
function test_AllowedElements_invalidElement() { function test_AllowedElements_invalidElement() {
$this->config->set('HTML', 'AllowedElements', 'obviously_invalid,p'); $this->config->set('HTML.AllowedElements', 'obviously_invalid,p');
$this->expectError(new PatternExpectation("/Element 'obviously_invalid' is not supported/")); $this->expectError(new PatternExpectation("/Element 'obviously_invalid' is not supported/"));
$this->assertPurification_AllowedElements_p(); $this->assertPurification_AllowedElements_p();
} }
function test_AllowedElements_invalidElement_xssAttempt() { function test_AllowedElements_invalidElement_xssAttempt() {
$this->config->set('HTML', 'AllowedElements', '<script>,p'); $this->config->set('HTML.AllowedElements', '<script>,p');
$this->expectError(new PatternExpectation("/Element '&lt;script&gt;' is not supported/")); $this->expectError(new PatternExpectation("/Element '&lt;script&gt;' is not supported/"));
$this->assertPurification_AllowedElements_p(); $this->assertPurification_AllowedElements_p();
} }
function test_AllowedElements_multipleInvalidElements() { function test_AllowedElements_multipleInvalidElements() {
$this->config->set('HTML', 'AllowedElements', 'dr-wiggles,dr-pepper,p'); $this->config->set('HTML.AllowedElements', 'dr-wiggles,dr-pepper,p');
$this->expectError(new PatternExpectation("/Element 'dr-wiggles' is not supported/")); $this->expectError(new PatternExpectation("/Element 'dr-wiggles' is not supported/"));
$this->expectError(new PatternExpectation("/Element 'dr-pepper' is not supported/")); $this->expectError(new PatternExpectation("/Element 'dr-pepper' is not supported/"));
$this->assertPurification_AllowedElements_p(); $this->assertPurification_AllowedElements_p();
@ -122,18 +122,18 @@ a[href|title]
} }
function test_AllowedAttributes_global_preferredSyntax() { function test_AllowedAttributes_global_preferredSyntax() {
$this->config->set('HTML', 'AllowedAttributes', 'style'); $this->config->set('HTML.AllowedAttributes', 'style');
$this->assertPurification_AllowedAttributes_global_style(); $this->assertPurification_AllowedAttributes_global_style();
} }
function test_AllowedAttributes_global_verboseSyntax() { function test_AllowedAttributes_global_verboseSyntax() {
$this->config->set('HTML', 'AllowedAttributes', '*@style'); $this->config->set('HTML.AllowedAttributes', '*@style');
$this->assertPurification_AllowedAttributes_global_style(); $this->assertPurification_AllowedAttributes_global_style();
} }
function test_AllowedAttributes_global_discouragedSyntax() { function test_AllowedAttributes_global_discouragedSyntax() {
// Emit errors eventually // Emit errors eventually
$this->config->set('HTML', 'AllowedAttributes', '*.style'); $this->config->set('HTML.AllowedAttributes', '*.style');
$this->assertPurification_AllowedAttributes_global_style(); $this->assertPurification_AllowedAttributes_global_style();
} }
@ -144,17 +144,17 @@ a[href|title]
} }
function test_AllowedAttributes_local_preferredSyntax() { function test_AllowedAttributes_local_preferredSyntax() {
$this->config->set('HTML', 'AllowedAttributes', 'p@style'); $this->config->set('HTML.AllowedAttributes', 'p@style');
$this->assertPurification_AllowedAttributes_local_p_style(); $this->assertPurification_AllowedAttributes_local_p_style();
} }
function test_AllowedAttributes_local_discouragedSyntax() { function test_AllowedAttributes_local_discouragedSyntax() {
$this->config->set('HTML', 'AllowedAttributes', 'p.style'); $this->config->set('HTML.AllowedAttributes', 'p.style');
$this->assertPurification_AllowedAttributes_local_p_style(); $this->assertPurification_AllowedAttributes_local_p_style();
} }
function test_AllowedAttributes_multiple() { function test_AllowedAttributes_multiple() {
$this->config->set('HTML', 'AllowedAttributes', 'p@style,br@class,title'); $this->config->set('HTML.AllowedAttributes', 'p@style,br@class,title');
$this->assertPurification( $this->assertPurification(
'<p style="font-weight:bold;" class="foo" title="foo">Jelly</p><br style="clear:both;" class="foo" title="foo" />', '<p style="font-weight:bold;" class="foo" title="foo">Jelly</p><br style="clear:both;" class="foo" title="foo" />',
'<p style="font-weight:bold;" title="foo">Jelly</p><br class="foo" title="foo" />' '<p style="font-weight:bold;" title="foo">Jelly</p><br class="foo" title="foo" />'
@ -162,42 +162,42 @@ a[href|title]
} }
function test_AllowedAttributes_local_invalidAttribute() { function test_AllowedAttributes_local_invalidAttribute() {
$this->config->set('HTML', 'AllowedAttributes', array('p@style', 'p@<foo>')); $this->config->set('HTML.AllowedAttributes', array('p@style', 'p@<foo>'));
$this->expectError(new PatternExpectation("/Attribute '&lt;foo&gt;' in element 'p' not supported/")); $this->expectError(new PatternExpectation("/Attribute '&lt;foo&gt;' in element 'p' not supported/"));
$this->assertPurification_AllowedAttributes_local_p_style(); $this->assertPurification_AllowedAttributes_local_p_style();
} }
function test_AllowedAttributes_global_invalidAttribute() { function test_AllowedAttributes_global_invalidAttribute() {
$this->config->set('HTML', 'AllowedAttributes', array('style', '<foo>')); $this->config->set('HTML.AllowedAttributes', array('style', '<foo>'));
$this->expectError(new PatternExpectation("/Global attribute '&lt;foo&gt;' is not supported in any elements/")); $this->expectError(new PatternExpectation("/Global attribute '&lt;foo&gt;' is not supported in any elements/"));
$this->assertPurification_AllowedAttributes_global_style(); $this->assertPurification_AllowedAttributes_global_style();
} }
function test_AllowedAttributes_local_invalidAttributeDueToMissingElement() { function test_AllowedAttributes_local_invalidAttributeDueToMissingElement() {
$this->config->set('HTML', 'AllowedAttributes', 'p.style,foo.style'); $this->config->set('HTML.AllowedAttributes', 'p.style,foo.style');
$this->expectError(new PatternExpectation("/Cannot allow attribute 'style' if element 'foo' is not allowed\/supported/")); $this->expectError(new PatternExpectation("/Cannot allow attribute 'style' if element 'foo' is not allowed\/supported/"));
$this->assertPurification_AllowedAttributes_local_p_style(); $this->assertPurification_AllowedAttributes_local_p_style();
} }
function test_AllowedAttributes_duplicate() { function test_AllowedAttributes_duplicate() {
$this->config->set('HTML', 'AllowedAttributes', 'p.style,p@style'); $this->config->set('HTML.AllowedAttributes', 'p.style,p@style');
$this->assertPurification_AllowedAttributes_local_p_style(); $this->assertPurification_AllowedAttributes_local_p_style();
} }
function test_AllowedAttributes_multipleErrors() { function test_AllowedAttributes_multipleErrors() {
$this->config->set('HTML', 'AllowedAttributes', 'p.style,foo.style,<foo>'); $this->config->set('HTML.AllowedAttributes', 'p.style,foo.style,<foo>');
$this->expectError(new PatternExpectation("/Cannot allow attribute 'style' if element 'foo' is not allowed\/supported/")); $this->expectError(new PatternExpectation("/Cannot allow attribute 'style' if element 'foo' is not allowed\/supported/"));
$this->expectError(new PatternExpectation("/Global attribute '&lt;foo&gt;' is not supported in any elements/")); $this->expectError(new PatternExpectation("/Global attribute '&lt;foo&gt;' is not supported in any elements/"));
$this->assertPurification_AllowedAttributes_local_p_style(); $this->assertPurification_AllowedAttributes_local_p_style();
} }
function test_ForbiddenElements() { function test_ForbiddenElements() {
$this->config->set('HTML', 'ForbiddenElements', 'b'); $this->config->set('HTML.ForbiddenElements', 'b');
$this->assertPurification('<b>b</b><i>i</i>', 'b<i>i</i>'); $this->assertPurification('<b>b</b><i>i</i>', 'b<i>i</i>');
} }
function test_ForbiddenElements_invalidElement() { function test_ForbiddenElements_invalidElement() {
$this->config->set('HTML', 'ForbiddenElements', 'obviously_incorrect'); $this->config->set('HTML.ForbiddenElements', 'obviously_incorrect');
// no error! // no error!
$this->assertPurification('<i>i</i>'); $this->assertPurification('<i>i</i>');
} }
@ -209,18 +209,18 @@ a[href|title]
} }
function test_ForbiddenAttributes() { function test_ForbiddenAttributes() {
$this->config->set('HTML', 'ForbiddenAttributes', 'b@style'); $this->config->set('HTML.ForbiddenAttributes', 'b@style');
$this->assertPurification_ForbiddenAttributes_b_style(); $this->assertPurification_ForbiddenAttributes_b_style();
} }
function test_ForbiddenAttributes_incorrectSyntax() { function test_ForbiddenAttributes_incorrectSyntax() {
$this->config->set('HTML', 'ForbiddenAttributes', 'b.style'); $this->config->set('HTML.ForbiddenAttributes', 'b.style');
$this->expectError("Error with b.style: tag.attr syntax not supported for HTML.ForbiddenAttributes; use tag@attr instead"); $this->expectError("Error with b.style: tag.attr syntax not supported for HTML.ForbiddenAttributes; use tag@attr instead");
$this->assertPurification('<b style="float:left;">Test</b>'); $this->assertPurification('<b style="float:left;">Test</b>');
} }
function test_ForbiddenAttributes_incorrectGlobalSyntax() { function test_ForbiddenAttributes_incorrectGlobalSyntax() {
$this->config->set('HTML', 'ForbiddenAttributes', '*.style'); $this->config->set('HTML.ForbiddenAttributes', '*.style');
$this->expectError("Error with *.style: *.attr syntax not supported for HTML.ForbiddenAttributes; use attr instead"); $this->expectError("Error with *.style: *.attr syntax not supported for HTML.ForbiddenAttributes; use attr instead");
$this->assertPurification('<b style="float:left;">Test</b>'); $this->assertPurification('<b style="float:left;">Test</b>');
} }
@ -232,12 +232,12 @@ a[href|title]
} }
function test_ForbiddenAttributes_global() { function test_ForbiddenAttributes_global() {
$this->config->set('HTML', 'ForbiddenAttributes', 'style'); $this->config->set('HTML.ForbiddenAttributes', 'style');
$this->assertPurification_ForbiddenAttributes_style(); $this->assertPurification_ForbiddenAttributes_style();
} }
function test_ForbiddenAttributes_globalVerboseFormat() { function test_ForbiddenAttributes_globalVerboseFormat() {
$this->config->set('HTML', 'ForbiddenAttributes', '*@style'); $this->config->set('HTML.ForbiddenAttributes', '*@style');
$this->assertPurification_ForbiddenAttributes_style(); $this->assertPurification_ForbiddenAttributes_style();
} }
@ -288,7 +288,7 @@ a[href|title]
} }
function test_injector() { function test_injector() {
$this->config->set('HTML', 'DefinitionID', 'HTMLPurifier_HTMLDefinitionTest->test_injector'); $this->config->set('HTML.DefinitionID', 'HTMLPurifier_HTMLDefinitionTest->test_injector');
generate_mock_once('HTMLPurifier_Injector'); generate_mock_once('HTMLPurifier_Injector');
$injector = new HTMLPurifier_InjectorMock(); $injector = new HTMLPurifier_InjectorMock();
@ -306,7 +306,7 @@ a[href|title]
} }
function test_injectorMissingNeeded() { function test_injectorMissingNeeded() {
$this->config->set('HTML', 'DefinitionID', 'HTMLPurifier_HTMLDefinitionTest->test_injectorMissingNeeded'); $this->config->set('HTML.DefinitionID', 'HTMLPurifier_HTMLDefinitionTest->test_injectorMissingNeeded');
generate_mock_once('HTMLPurifier_Injector'); generate_mock_once('HTMLPurifier_Injector');
$injector = new HTMLPurifier_InjectorMock(); $injector = new HTMLPurifier_InjectorMock();
@ -322,7 +322,7 @@ a[href|title]
} }
function test_injectorIntegration() { function test_injectorIntegration() {
$this->config->set('HTML', 'DefinitionID', 'HTMLPurifier_HTMLDefinitionTest->test_injectorIntegration'); $this->config->set('HTML.DefinitionID', 'HTMLPurifier_HTMLDefinitionTest->test_injectorIntegration');
$module = $this->config->getHTMLDefinition(true)->getAnonymousModule(); $module = $this->config->getHTMLDefinition(true)->getAnonymousModule();
$module->info_injector[] = 'Linkify'; $module->info_injector[] = 'Linkify';
@ -334,9 +334,9 @@ a[href|title]
} }
function test_injectorIntegrationFail() { function test_injectorIntegrationFail() {
$this->config->set('HTML', 'DefinitionID', 'HTMLPurifier_HTMLDefinitionTest->test_injectorIntegrationFail'); $this->config->set('HTML.DefinitionID', 'HTMLPurifier_HTMLDefinitionTest->test_injectorIntegrationFail');
$this->config->set('HTML', 'Allowed', 'p'); $this->config->set('HTML.Allowed', 'p');
$module = $this->config->getHTMLDefinition(true)->getAnonymousModule(); $module = $this->config->getHTMLDefinition(true)->getAnonymousModule();
$module->info_injector[] = 'Linkify'; $module->info_injector[] = 'Linkify';

View File

@ -5,9 +5,9 @@ class HTMLPurifier_HTMLModule_FormsTest extends HTMLPurifier_HTMLModuleHarness
function setUp() { function setUp() {
parent::setUp(); parent::setUp();
$this->config->set('HTML', 'Trusted', true); $this->config->set('HTML.Trusted', true);
$this->config->set('Attr', 'EnableID', true); $this->config->set('Attr.EnableID', true);
$this->config->set('Cache', 'DefinitionImpl', null); $this->config->set('Cache.DefinitionImpl', null);
} }
function testBasicUse() { function testBasicUse() {

View File

@ -23,7 +23,7 @@ class HTMLPurifier_HTMLModule_ImageTest extends HTMLPurifier_HTMLModuleHarness
} }
function testLengthCustomMax() { function testLengthCustomMax() {
$this->config->set('HTML', 'MaxImgLength', 20); $this->config->set('HTML.MaxImgLength', 20);
$this->assertResult( $this->assertResult(
'<img height="30" width="30" src="" alt="" />', '<img height="30" width="30" src="" alt="" />',
'<img height="20" width="20" src="" alt="" />' '<img height="20" width="20" src="" alt="" />'
@ -31,7 +31,7 @@ class HTMLPurifier_HTMLModule_ImageTest extends HTMLPurifier_HTMLModuleHarness
} }
function testLengthCrashFixDisabled() { function testLengthCrashFixDisabled() {
$this->config->set('HTML', 'MaxImgLength', null); $this->config->set('HTML.MaxImgLength', null);
$this->assertResult( $this->assertResult(
'<img height="100%" width="100%" src="" alt="" />' '<img height="100%" width="100%" src="" alt="" />'
); );
@ -41,7 +41,7 @@ class HTMLPurifier_HTMLModule_ImageTest extends HTMLPurifier_HTMLModuleHarness
} }
function testLengthTrusted() { function testLengthTrusted() {
$this->config->set('HTML', 'Trusted', true); $this->config->set('HTML.Trusted', true);
$this->assertResult( $this->assertResult(
'<img height="100%" width="100%" src="" alt="" />' '<img height="100%" width="100%" src="" alt="" />'
); );

View File

@ -5,11 +5,11 @@ class HTMLPurifier_HTMLModule_ObjectTest extends HTMLPurifier_HTMLModuleHarness
function setUp() { function setUp() {
parent::setUp(); parent::setUp();
$this->config->set('HTML', 'Trusted', true); $this->config->set('HTML.Trusted', true);
} }
function testDefaultRemoval() { function testDefaultRemoval() {
$this->config->set('HTML', 'Trusted', false); $this->config->set('HTML.Trusted', false);
$this->assertResult( $this->assertResult(
'<object></object>', '' '<object></object>', ''
); );

View File

@ -5,7 +5,7 @@ class HTMLPurifier_HTMLModule_ProprietaryTest extends HTMLPurifier_HTMLModuleHar
function setUp() { function setUp() {
parent::setUp(); parent::setUp();
$this->config->set('HTML', 'Proprietary', true); $this->config->set('HTML.Proprietary', true);
} }
function testMarquee() { function testMarquee() {

View File

@ -5,7 +5,7 @@ class HTMLPurifier_HTMLModule_RubyTest extends HTMLPurifier_HTMLModuleHarness
function setUp() { function setUp() {
parent::setUp(); parent::setUp();
$this->config->set('HTML', 'Doctype', 'XHTML 1.1'); $this->config->set('HTML.Doctype', 'XHTML 1.1');
} }
function testBasicUse() { function testBasicUse() {

View File

@ -5,7 +5,7 @@ class HTMLPurifier_HTMLModule_SafeEmbedTest extends HTMLPurifier_HTMLModuleHarne
function setUp() { function setUp() {
parent::setUp(); parent::setUp();
$this->config->set('HTML', 'DefinitionID', 'HTMLPurifier_HTMLModule_SafeEmbedTest'); $this->config->set('HTML.DefinitionID', 'HTMLPurifier_HTMLModule_SafeEmbedTest');
$def = $this->config->getHTMLDefinition(true); $def = $this->config->getHTMLDefinition(true);
$def->manager->addModule('SafeEmbed'); $def->manager->addModule('SafeEmbed');
} }

View File

@ -5,7 +5,7 @@ class HTMLPurifier_HTMLModule_SafeObjectTest extends HTMLPurifier_HTMLModuleHarn
function setUp() { function setUp() {
parent::setUp(); parent::setUp();
$this->config->set('HTML', 'DefinitionID', 'HTMLPurifier_HTMLModule_SafeObjectTest'); $this->config->set('HTML.DefinitionID', 'HTMLPurifier_HTMLModule_SafeObjectTest');
$def = $this->config->getHTMLDefinition(true); $def = $this->config->getHTMLDefinition(true);
$def->manager->addModule('SafeObject'); $def->manager->addModule('SafeObject');
} }

View File

@ -5,12 +5,12 @@ class HTMLPurifier_HTMLModule_ScriptingTest extends HTMLPurifier_HTMLModuleHarne
function setUp() { function setUp() {
parent::setUp(); parent::setUp();
$this->config->set('HTML', 'Trusted', true); $this->config->set('HTML.Trusted', true);
$this->config->set('Output', 'CommentScriptContents', false); $this->config->set('Output.CommentScriptContents', false);
} }
function testDefaultRemoval() { function testDefaultRemoval() {
$this->config->set('HTML', 'Trusted', false); $this->config->set('HTML.Trusted', false);
$this->assertResult( $this->assertResult(
'<script type="text/javascript">foo();</script>', '' '<script type="text/javascript">foo();</script>', ''
); );

View File

@ -6,7 +6,7 @@ class HTMLPurifier_HTMLModuleManagerTest extends HTMLPurifier_Harness
protected function createManager() { protected function createManager() {
$manager = new HTMLPurifier_HTMLModuleManager(); $manager = new HTMLPurifier_HTMLModuleManager();
$this->config->set('HTML', 'CustomDoctype', 'Blank'); $this->config->set('HTML.CustomDoctype', 'Blank');
$manager->doctypes->register('Blank'); $manager->doctypes->register('Blank');
$attrdef_nmtokens = new HTMLPurifier_AttrDef_HTML_Nmtokens(); $attrdef_nmtokens = new HTMLPurifier_AttrDef_HTML_Nmtokens();
@ -47,8 +47,8 @@ class HTMLPurifier_HTMLModuleManagerTest extends HTMLPurifier_Harness
$manager->addModule($unsafe_module); $manager->addModule($unsafe_module);
$config = HTMLPurifier_Config::createDefault(); $config = HTMLPurifier_Config::createDefault();
$config->set('HTML', 'Trusted', false); $config->set('HTML.Trusted', false);
$config->set('HTML', 'CustomDoctype', 'Blank'); $config->set('HTML.CustomDoctype', 'Blank');
$manager->setup($config); $manager->setup($config);

View File

@ -15,7 +15,7 @@ class HTMLPurifier_HTMLT extends HTMLPurifier_Harness
if (isset($hash['SKIPIF'])) { if (isset($hash['SKIPIF'])) {
if (eval($hash['SKIPIF'])) return; if (eval($hash['SKIPIF'])) return;
} }
$this->config->set('Output', 'Newline', "\n"); $this->config->set('Output.Newline', "\n");
if (isset($hash['INI'])) { if (isset($hash['INI'])) {
// there should be a more efficient way than writing another // there should be a more efficient way than writing another
// ini file every time... probably means building a parser for // ini file every time... probably means building a parser for

View File

@ -18,7 +18,7 @@ class HTMLPurifier_Harness extends UnitTestCase
*/ */
public function setUp() { public function setUp() {
list($this->config, $this->context) = $this->createCommon(); list($this->config, $this->context) = $this->createCommon();
$this->config->set('Output', 'Newline', ' $this->config->set('Output.Newline', '
'); ');
$this->purifier = new HTMLPurifier(); $this->purifier = new HTMLPurifier();
} }

View File

@ -29,7 +29,7 @@ class HTMLPurifier_IDAccumulatorTest extends HTMLPurifier_Harness
} }
function testBuild() { function testBuild() {
$this->config->set('Attr', 'IDBlacklist', array('foo')); $this->config->set('Attr.IDBlacklist', array('foo'));
$accumulator = HTMLPurifier_IDAccumulator::build($this->config, $this->context); $accumulator = HTMLPurifier_IDAccumulator::build($this->config, $this->context);
$this->assertTrue( isset($accumulator->ids['foo']) ); $this->assertTrue( isset($accumulator->ids['foo']) );
} }

View File

@ -5,7 +5,7 @@ class HTMLPurifier_Injector_AutoParagraphTest extends HTMLPurifier_InjectorHarne
function setup() { function setup() {
parent::setup(); parent::setup();
$this->config->set('AutoFormat', 'AutoParagraph', true); $this->config->set('AutoFormat.AutoParagraph', true);
} }
function testSingleParagraph() { function testSingleParagraph() {
@ -385,7 +385,7 @@ Par1
} }
function testNoParagraphWithInlineRootNode() { function testNoParagraphWithInlineRootNode() {
$this->config->set('HTML', 'Parent', 'span'); $this->config->set('HTML.Parent', 'span');
$this->assertResult( $this->assertResult(
'Par 'Par
@ -498,7 +498,7 @@ Bar</div>",
} }
function testErrorNeeded() { function testErrorNeeded() {
$this->config->set('HTML', 'Allowed', 'b'); $this->config->set('HTML.Allowed', 'b');
$this->expectError('Cannot enable AutoParagraph injector because p is not allowed'); $this->expectError('Cannot enable AutoParagraph injector because p is not allowed');
$this->assertResult('<b>foobar</b>'); $this->assertResult('<b>foobar</b>');
} }

View File

@ -5,7 +5,7 @@ class HTMLPurifier_Injector_DisplayLinkURITest extends HTMLPurifier_InjectorHarn
function setup() { function setup() {
parent::setup(); parent::setup();
$this->config->set('AutoFormat', 'DisplayLinkURI', true); $this->config->set('AutoFormat.DisplayLinkURI', true);
} }
function testBasicLink() { function testBasicLink() {

View File

@ -5,7 +5,7 @@ class HTMLPurifier_Injector_LinkifyTest extends HTMLPurifier_InjectorHarness
function setup() { function setup() {
parent::setup(); parent::setup();
$this->config->set('AutoFormat', 'Linkify', true); $this->config->set('AutoFormat.Linkify', true);
} }
function testLinkifyURLInRootNode() { function testLinkifyURLInRootNode() {
@ -36,7 +36,7 @@ class HTMLPurifier_Injector_LinkifyTest extends HTMLPurifier_InjectorHarness
} }
function testNeeded() { function testNeeded() {
$this->config->set('HTML', 'Allowed', 'b'); $this->config->set('HTML.Allowed', 'b');
$this->expectError('Cannot enable Linkify injector because a is not allowed'); $this->expectError('Cannot enable Linkify injector because a is not allowed');
$this->assertResult('http://example.com/'); $this->assertResult('http://example.com/');
} }

View File

@ -5,8 +5,8 @@ class HTMLPurifier_Injector_PurifierLinkifyTest extends HTMLPurifier_InjectorHar
function setup() { function setup() {
parent::setup(); parent::setup();
$this->config->set('AutoFormat', 'PurifierLinkify', true); $this->config->set('AutoFormat.PurifierLinkify', true);
$this->config->set('AutoFormatParam', 'PurifierLinkifyDocURL', '#%s'); $this->config->set('AutoFormatParam.PurifierLinkifyDocURL', '#%s');
} }
function testNoTriggerCharacer() { function testNoTriggerCharacer() {
@ -49,7 +49,7 @@ class HTMLPurifier_Injector_PurifierLinkifyTest extends HTMLPurifier_InjectorHar
} }
function testNeeded() { function testNeeded() {
$this->config->set('HTML', 'Allowed', 'b'); $this->config->set('HTML.Allowed', 'b');
$this->expectError('Cannot enable PurifierLinkify injector because a is not allowed'); $this->expectError('Cannot enable PurifierLinkify injector because a is not allowed');
$this->assertResult('%Namespace.Directive'); $this->assertResult('%Namespace.Directive');
} }

View File

@ -5,7 +5,7 @@ class HTMLPurifier_Injector_RemoveEmptyTest extends HTMLPurifier_InjectorHarness
public function setup() { public function setup() {
parent::setup(); parent::setup();
$this->config->set('AutoFormat', 'RemoveEmpty', true); $this->config->set('AutoFormat.RemoveEmpty', true);
} }
function testPreserve() { function testPreserve() {
@ -33,12 +33,12 @@ class HTMLPurifier_Injector_RemoveEmptyTest extends HTMLPurifier_InjectorHarness
} }
function testPreserveId() { function testPreserveId() {
$this->config->set('Attr', 'EnableID', true); $this->config->set('Attr.EnableID', true);
$this->assertResult('<a id="asdf"></a>'); $this->assertResult('<a id="asdf"></a>');
} }
function testPreserveName() { function testPreserveName() {
$this->config->set('Attr', 'EnableID', true); $this->config->set('Attr.EnableID', true);
$this->assertResult('<a name="asdf"></a>'); $this->assertResult('<a name="asdf"></a>');
} }

View File

@ -11,8 +11,8 @@ class HTMLPurifier_Injector_SafeObjectTest extends HTMLPurifier_InjectorHarness
function setup() { function setup() {
parent::setup(); parent::setup();
// there is no AutoFormat.SafeObject directive // there is no AutoFormat.SafeObject directive
$this->config->set('AutoFormat', 'Custom', array(new HTMLPurifier_Injector_SafeObject())); $this->config->set('AutoFormat.Custom', array(new HTMLPurifier_Injector_SafeObject()));
$this->config->set('HTML', 'Trusted', true); $this->config->set('HTML.Trusted', true);
} }
function testPreserve() { function testPreserve() {

View File

@ -15,7 +15,7 @@ class HTMLPurifier_LanguageFactoryTest extends HTMLPurifier_Harness
function test() { function test() {
$this->config->set('Core', 'Language', 'en'); $this->config->set('Core.Language', 'en');
$language = $this->factory->create($this->config, $this->context); $language = $this->factory->create($this->config, $this->context);
$this->assertIsA($language, 'HTMLPurifier_Language'); $this->assertIsA($language, 'HTMLPurifier_Language');
@ -30,7 +30,7 @@ class HTMLPurifier_LanguageFactoryTest extends HTMLPurifier_Harness
function testFallback() { function testFallback() {
$this->config->set('Core', 'Language', 'en-x-test'); $this->config->set('Core.Language', 'en-x-test');
$language = $this->factory->create($this->config, $this->context); $language = $this->factory->create($this->config, $this->context);
$this->assertIsA($language, 'HTMLPurifier_Language_en_x_test'); $this->assertIsA($language, 'HTMLPurifier_Language_en_x_test');
@ -47,7 +47,7 @@ class HTMLPurifier_LanguageFactoryTest extends HTMLPurifier_Harness
} }
function testFallbackWithNoClass() { function testFallbackWithNoClass() {
$this->config->set('Core', 'Language', 'en-x-testmini'); $this->config->set('Core.Language', 'en-x-testmini');
$language = $this->factory->create($this->config, $this->context); $language = $this->factory->create($this->config, $this->context);
$this->assertIsA($language, 'HTMLPurifier_Language'); $this->assertIsA($language, 'HTMLPurifier_Language');
$this->assertIdentical($language->code, 'en-x-testmini'); $this->assertIdentical($language->code, 'en-x-testmini');
@ -58,7 +58,7 @@ class HTMLPurifier_LanguageFactoryTest extends HTMLPurifier_Harness
} }
function testNoSuchLanguage() { function testNoSuchLanguage() {
$this->config->set('Core', 'Language', 'en-x-testnone'); $this->config->set('Core.Language', 'en-x-testnone');
$language = $this->factory->create($this->config, $this->context); $language = $this->factory->create($this->config, $this->context);
$this->assertIsA($language, 'HTMLPurifier_Language'); $this->assertIsA($language, 'HTMLPurifier_Language');
$this->assertIdentical($language->code, 'en-x-testnone'); $this->assertIdentical($language->code, 'en-x-testnone');

View File

@ -24,26 +24,26 @@ class HTMLPurifier_LexerTest extends HTMLPurifier_Harness
// HTMLPurifier_Lexer::create() -------------------------------------------- // HTMLPurifier_Lexer::create() --------------------------------------------
function test_create() { function test_create() {
$this->config->set('Core', 'MaintainLineNumbers', true); $this->config->set('Core.MaintainLineNumbers', true);
$lexer = HTMLPurifier_Lexer::create($this->config); $lexer = HTMLPurifier_Lexer::create($this->config);
$this->assertIsA($lexer, 'HTMLPurifier_Lexer_DirectLex'); $this->assertIsA($lexer, 'HTMLPurifier_Lexer_DirectLex');
} }
function test_create_objectLexerImpl() { function test_create_objectLexerImpl() {
$this->config->set('Core', 'LexerImpl', new HTMLPurifier_Lexer_DirectLex()); $this->config->set('Core.LexerImpl', new HTMLPurifier_Lexer_DirectLex());
$lexer = HTMLPurifier_Lexer::create($this->config); $lexer = HTMLPurifier_Lexer::create($this->config);
$this->assertIsA($lexer, 'HTMLPurifier_Lexer_DirectLex'); $this->assertIsA($lexer, 'HTMLPurifier_Lexer_DirectLex');
} }
function test_create_unknownLexer() { function test_create_unknownLexer() {
$this->config->set('Core', 'LexerImpl', 'AsdfAsdf'); $this->config->set('Core.LexerImpl', 'AsdfAsdf');
$this->expectException(new HTMLPurifier_Exception('Cannot instantiate unrecognized Lexer type AsdfAsdf')); $this->expectException(new HTMLPurifier_Exception('Cannot instantiate unrecognized Lexer type AsdfAsdf'));
HTMLPurifier_Lexer::create($this->config); HTMLPurifier_Lexer::create($this->config);
} }
function test_create_incompatibleLexer() { function test_create_incompatibleLexer() {
$this->config->set('Core', 'LexerImpl', 'DOMLex'); $this->config->set('Core.LexerImpl', 'DOMLex');
$this->config->set('Core', 'MaintainLineNumbers', true); $this->config->set('Core.MaintainLineNumbers', true);
$this->expectException(new HTMLPurifier_Exception('Cannot use lexer that does not support line numbers with Core.MaintainLineNumbers or Core.CollectErrors (use DirectLex instead)')); $this->expectException(new HTMLPurifier_Exception('Cannot use lexer that does not support line numbers with Core.MaintainLineNumbers or Core.CollectErrors (use DirectLex instead)'));
HTMLPurifier_Lexer::create($this->config); HTMLPurifier_Lexer::create($this->config);
} }
@ -491,7 +491,7 @@ class HTMLPurifier_LexerTest extends HTMLPurifier_Harness
} }
function test_tokenizeHTML_scriptCDATAContents() { function test_tokenizeHTML_scriptCDATAContents() {
$this->config->set('HTML', 'Trusted', true); $this->config->set('HTML.Trusted', true);
$this->assertTokenization( $this->assertTokenization(
'Foo: <script>alert("<foo>");</script>', 'Foo: <script>alert("<foo>");</script>',
array( array(

View File

@ -24,7 +24,7 @@ class HTMLPurifier_Strategy_FixNestingTest extends HTMLPurifier_StrategyHarness
} }
function testEscapeBlockInInline() { function testEscapeBlockInInline() {
$this->config->set('Core', 'EscapeInvalidChildren', true); $this->config->set('Core.EscapeInvalidChildren', true);
$this->assertResult( $this->assertResult(
'<b><div>Illegal div.</div></b>', '<b><div>Illegal div.</div></b>',
'<b>&lt;div&gt;Illegal div.&lt;/div&gt;</b>' '<b>&lt;div&gt;Illegal div.&lt;/div&gt;</b>'
@ -78,7 +78,7 @@ class HTMLPurifier_Strategy_FixNestingTest extends HTMLPurifier_StrategyHarness
} }
function testChameleonEscapeInvalidBlockInInline() { function testChameleonEscapeInvalidBlockInInline() {
$this->config->set('Core', 'EscapeInvalidChildren', true); $this->config->set('Core.EscapeInvalidChildren', true);
$this->assertResult( // alt config $this->assertResult( // alt config
'<span><ins><div>Not allowed!</div></ins></span>', '<span><ins><div>Not allowed!</div></ins></span>',
'<span><ins>&lt;div&gt;Not allowed!&lt;/div&gt;</ins></span>' '<span><ins>&lt;div&gt;Not allowed!&lt;/div&gt;</ins></span>'
@ -94,19 +94,19 @@ class HTMLPurifier_Strategy_FixNestingTest extends HTMLPurifier_StrategyHarness
} }
function testPreserveInlineNodeInInlineRootNode() { function testPreserveInlineNodeInInlineRootNode() {
$this->config->set('HTML', 'Parent', 'span'); $this->config->set('HTML.Parent', 'span');
$this->assertResult('<b>Bold</b>'); $this->assertResult('<b>Bold</b>');
} }
function testRemoveBlockNodeInInlineRootNode() { function testRemoveBlockNodeInInlineRootNode() {
$this->config->set('HTML', 'Parent', 'span'); $this->config->set('HTML.Parent', 'span');
$this->assertResult('<div>Reject</div>', 'Reject'); $this->assertResult('<div>Reject</div>', 'Reject');
} }
function testInvalidParentError() { function testInvalidParentError() {
// test fallback to div // test fallback to div
$this->config->set('HTML', 'Parent', 'obviously-impossible'); $this->config->set('HTML.Parent', 'obviously-impossible');
$this->config->set('Cache', 'DefinitionImpl', null); $this->config->set('Cache.DefinitionImpl', null);
$this->expectError('Cannot use unrecognized element as parent'); $this->expectError('Cannot use unrecognized element as parent');
$this->assertResult('<div>Accept</div>'); $this->assertResult('<div>Accept</div>');
} }
@ -128,7 +128,7 @@ class HTMLPurifier_Strategy_FixNestingTest extends HTMLPurifier_StrategyHarness
} }
function testStrictBlockquoteInHTML401() { function testStrictBlockquoteInHTML401() {
$this->config->set('HTML', 'Doctype', 'HTML 4.01 Strict'); $this->config->set('HTML.Doctype', 'HTML 4.01 Strict');
$this->assertResult('<blockquote>text</blockquote>', '<blockquote><p>text</p></blockquote>'); $this->assertResult('<blockquote>text</blockquote>', '<blockquote><p>text</p></blockquote>');
} }

View File

@ -5,7 +5,7 @@ class HTMLPurifier_Strategy_MakeWellFormed_EndInsertInjectorTest extends HTMLPur
function setUp() { function setUp() {
parent::setUp(); parent::setUp();
$this->obj = new HTMLPurifier_Strategy_MakeWellFormed(); $this->obj = new HTMLPurifier_Strategy_MakeWellFormed();
$this->config->set('AutoFormat', 'Custom', array( $this->config->set('AutoFormat.Custom', array(
new HTMLPurifier_Strategy_MakeWellFormed_EndInsertInjector() new HTMLPurifier_Strategy_MakeWellFormed_EndInsertInjector()
)); ));
} }

View File

@ -5,7 +5,7 @@ class HTMLPurifier_Strategy_MakeWellFormed_EndRewindInjectorTest extends HTMLPur
function setUp() { function setUp() {
parent::setUp(); parent::setUp();
$this->obj = new HTMLPurifier_Strategy_MakeWellFormed(); $this->obj = new HTMLPurifier_Strategy_MakeWellFormed();
$this->config->set('AutoFormat', 'Custom', array( $this->config->set('AutoFormat.Custom', array(
new HTMLPurifier_Strategy_MakeWellFormed_EndRewindInjector() new HTMLPurifier_Strategy_MakeWellFormed_EndRewindInjector()
)); ));
} }
@ -22,7 +22,7 @@ class HTMLPurifier_Strategy_MakeWellFormed_EndRewindInjectorTest extends HTMLPur
$this->assertResult('<b></b><span>asdf</span><b></b>','<b></b><b></b>'); $this->assertResult('<b></b><span>asdf</span><b></b>','<b></b><b></b>');
} }
function testDoubled() { function testDoubled() {
$this->config->set('AutoFormat', 'Custom', array( $this->config->set('AutoFormat.Custom', array(
new HTMLPurifier_Strategy_MakeWellFormed_EndRewindInjector(), new HTMLPurifier_Strategy_MakeWellFormed_EndRewindInjector(),
new HTMLPurifier_Strategy_MakeWellFormed_EndRewindInjector(), new HTMLPurifier_Strategy_MakeWellFormed_EndRewindInjector(),
)); ));

View File

@ -5,7 +5,7 @@ class HTMLPurifier_Strategy_MakeWellFormed_SkipInjectorTest extends HTMLPurifier
function setUp() { function setUp() {
parent::setUp(); parent::setUp();
$this->obj = new HTMLPurifier_Strategy_MakeWellFormed(); $this->obj = new HTMLPurifier_Strategy_MakeWellFormed();
$this->config->set('AutoFormat', 'Custom', array( $this->config->set('AutoFormat.Custom', array(
new HTMLPurifier_Strategy_MakeWellFormed_SkipInjector() new HTMLPurifier_Strategy_MakeWellFormed_SkipInjector()
)); ));
} }
@ -16,7 +16,7 @@ class HTMLPurifier_Strategy_MakeWellFormed_SkipInjectorTest extends HTMLPurifier
$this->assertResult('<br />', '<br /><br />'); $this->assertResult('<br />', '<br /><br />');
} }
function testMultiplyMultiply() { function testMultiplyMultiply() {
$this->config->set('AutoFormat', 'Custom', array( $this->config->set('AutoFormat.Custom', array(
new HTMLPurifier_Strategy_MakeWellFormed_SkipInjector(), new HTMLPurifier_Strategy_MakeWellFormed_SkipInjector(),
new HTMLPurifier_Strategy_MakeWellFormed_SkipInjector() new HTMLPurifier_Strategy_MakeWellFormed_SkipInjector()
)); ));

View File

@ -94,7 +94,7 @@ class HTMLPurifier_Strategy_MakeWellFormedTest extends HTMLPurifier_StrategyHarn
} }
function testBlockquoteWithInline() { function testBlockquoteWithInline() {
$this->config->set('HTML', 'Doctype', 'XHTML 1.0 Strict'); $this->config->set('HTML.Doctype', 'XHTML 1.0 Strict');
$this->assertResult( $this->assertResult(
// This is actually invalid, but will be fixed by // This is actually invalid, but will be fixed by
// ChildDef_StrictBlockquote // ChildDef_StrictBlockquote

View File

@ -14,7 +14,7 @@ class HTMLPurifier_Strategy_MakeWellFormed_ErrorsTest extends HTMLPurifier_Strat
} }
function testUnnecessaryEndTagToText() { function testUnnecessaryEndTagToText() {
$this->config->set('Core', 'EscapeInvalidTags', true); $this->config->set('Core.EscapeInvalidTags', true);
$this->expectErrorCollection(E_WARNING, 'Strategy_MakeWellFormed: Unnecessary end tag to text'); $this->expectErrorCollection(E_WARNING, 'Strategy_MakeWellFormed: Unnecessary end tag to text');
$this->expectContext('CurrentToken', new HTMLPurifier_Token_End('b', array(), 1, 0)); $this->expectContext('CurrentToken', new HTMLPurifier_Token_End('b', array(), 1, 0));
$this->invoke('</b>'); $this->invoke('</b>');
@ -40,7 +40,7 @@ class HTMLPurifier_Strategy_MakeWellFormed_ErrorsTest extends HTMLPurifier_Strat
} }
function testStrayEndTagToText() { function testStrayEndTagToText() {
$this->config->set('Core', 'EscapeInvalidTags', true); $this->config->set('Core.EscapeInvalidTags', true);
$this->expectErrorCollection(E_WARNING, 'Strategy_MakeWellFormed: Stray end tag to text'); $this->expectErrorCollection(E_WARNING, 'Strategy_MakeWellFormed: Stray end tag to text');
$this->expectContext('CurrentToken', new HTMLPurifier_Token_End('b', array(), 1, 3)); $this->expectContext('CurrentToken', new HTMLPurifier_Token_End('b', array(), 1, 3));
$this->invoke('<i></b></i>'); $this->invoke('<i></b></i>');

View File

@ -6,9 +6,9 @@ class HTMLPurifier_Strategy_MakeWellFormed_InjectorTest extends HTMLPurifier_Str
function setUp() { function setUp() {
parent::setUp(); parent::setUp();
$this->obj = new HTMLPurifier_Strategy_MakeWellFormed(); $this->obj = new HTMLPurifier_Strategy_MakeWellFormed();
$this->config->set('AutoFormat', 'AutoParagraph', true); $this->config->set('AutoFormat.AutoParagraph', true);
$this->config->set('AutoFormat', 'Linkify', true); $this->config->set('AutoFormat.Linkify', true);
$this->config->set('AutoFormat', 'RemoveEmpty', true); $this->config->set('AutoFormat.RemoveEmpty', true);
generate_mock_once('HTMLPurifier_Injector'); generate_mock_once('HTMLPurifier_Injector');
} }
@ -26,21 +26,21 @@ class HTMLPurifier_Strategy_MakeWellFormed_InjectorTest extends HTMLPurifier_Str
$mock->expectAt(1, 'handleEnd', array($i)); $mock->expectAt(1, 'handleEnd', array($i));
$mock->expectCallCount('handleEnd', 2); $mock->expectCallCount('handleEnd', 2);
$mock->setReturnValue('getRewind', false); $mock->setReturnValue('getRewind', false);
$this->config->set('AutoFormat', 'AutoParagraph', false); $this->config->set('AutoFormat.AutoParagraph', false);
$this->config->set('AutoFormat', 'Linkify', false); $this->config->set('AutoFormat.Linkify', false);
$this->config->set('AutoFormat', 'Custom', array($mock)); $this->config->set('AutoFormat.Custom', array($mock));
$this->assertResult('<i><b>asdf</b>', '<i><b>asdf</b></i>'); $this->assertResult('<i><b>asdf</b>', '<i><b>asdf</b></i>');
} }
function testErrorRequiredElementNotAllowed() { function testErrorRequiredElementNotAllowed() {
$this->config->set('HTML', 'Allowed', ''); $this->config->set('HTML.Allowed', '');
$this->expectError('Cannot enable AutoParagraph injector because p is not allowed'); $this->expectError('Cannot enable AutoParagraph injector because p is not allowed');
$this->expectError('Cannot enable Linkify injector because a is not allowed'); $this->expectError('Cannot enable Linkify injector because a is not allowed');
$this->assertResult('Foobar'); $this->assertResult('Foobar');
} }
function testErrorRequiredAttributeNotAllowed() { function testErrorRequiredAttributeNotAllowed() {
$this->config->set('HTML', 'Allowed', 'a,p'); $this->config->set('HTML.Allowed', 'a,p');
$this->expectError('Cannot enable Linkify injector because a.href is not allowed'); $this->expectError('Cannot enable Linkify injector because a.href is not allowed');
$this->assertResult('<p>http://example.com</p>'); $this->assertResult('<p>http://example.com</p>');
} }

View File

@ -38,7 +38,7 @@ class HTMLPurifier_Strategy_RemoveForeignElementsTest extends HTMLPurifier_Strat
} }
function testRemoveOnlyScriptTagsLegacy() { function testRemoveOnlyScriptTagsLegacy() {
$this->config->set('Core', 'RemoveScriptContents', false); $this->config->set('Core.RemoveScriptContents', false);
$this->assertResult( $this->assertResult(
'<script>alert();</script>', '<script>alert();</script>',
'alert();' 'alert();'
@ -46,7 +46,7 @@ class HTMLPurifier_Strategy_RemoveForeignElementsTest extends HTMLPurifier_Strat
} }
function testRemoveOnlyScriptTags() { function testRemoveOnlyScriptTags() {
$this->config->set('Core', 'HiddenElements', array()); $this->config->set('Core.HiddenElements', array());
$this->assertResult( $this->assertResult(
'<script>alert();</script>', '<script>alert();</script>',
'alert();' 'alert();'
@ -62,13 +62,13 @@ class HTMLPurifier_Strategy_RemoveForeignElementsTest extends HTMLPurifier_Strat
} }
function testPreserveInvalidImgWhenRemovalIsDisabled() { function testPreserveInvalidImgWhenRemovalIsDisabled() {
$this->config->set('Core', 'RemoveInvalidImg', false); $this->config->set('Core.RemoveInvalidImg', false);
$this->assertResult('<img />'); $this->assertResult('<img />');
} }
function testTextifyCommentedScriptContents() { function testTextifyCommentedScriptContents() {
$this->config->set('HTML', 'Trusted', true); $this->config->set('HTML.Trusted', true);
$this->config->set('Output', 'CommentScriptContents', false); // simplify output $this->config->set('Output.CommentScriptContents', false); // simplify output
$this->assertResult( $this->assertResult(
'<script type="text/javascript"><!-- '<script type="text/javascript"><!--
alert(<b>bold</b>); alert(<b>bold</b>);
@ -80,7 +80,7 @@ alert(&lt;b&gt;bold&lt;/b&gt;);
} }
function testRequiredAttributesTestNotPerformedOnEndTag() { function testRequiredAttributesTestNotPerformedOnEndTag() {
$this->config->set('HTML', 'DefinitionID', $this->config->set('HTML.DefinitionID',
'HTMLPurifier_Strategy_RemoveForeignElementsTest'. 'HTMLPurifier_Strategy_RemoveForeignElementsTest'.
'->testRequiredAttributesTestNotPerformedOnEndTag'); '->testRequiredAttributesTestNotPerformedOnEndTag');
$def = $this->config->getHTMLDefinition(true); $def = $this->config->getHTMLDefinition(true);
@ -89,17 +89,17 @@ alert(&lt;b&gt;bold&lt;/b&gt;);
} }
function testPreserveCommentsWithHTMLTrusted() { function testPreserveCommentsWithHTMLTrusted() {
$this->config->set('HTML', 'Trusted', true); $this->config->set('HTML.Trusted', true);
$this->assertResult('<!-- foo -->'); $this->assertResult('<!-- foo -->');
} }
function testRemoveTrailingHyphensInComment() { function testRemoveTrailingHyphensInComment() {
$this->config->set('HTML', 'Trusted', true); $this->config->set('HTML.Trusted', true);
$this->assertResult('<!-- foo ----->', '<!-- foo -->'); $this->assertResult('<!-- foo ----->', '<!-- foo -->');
} }
function testCollapseDoubleHyphensInComment() { function testCollapseDoubleHyphensInComment() {
$this->config->set('HTML', 'Trusted', true); $this->config->set('HTML.Trusted', true);
$this->assertResult('<!-- bo --- asdf--as -->', '<!-- bo - asdf-as -->'); $this->assertResult('<!-- bo --- asdf--as -->', '<!-- bo - asdf-as -->');
} }

View File

@ -5,7 +5,7 @@ class HTMLPurifier_Strategy_RemoveForeignElements_ErrorsTest extends HTMLPurifie
public function setup() { public function setup() {
parent::setup(); parent::setup();
$this->config->set('HTML', 'TidyLevel', 'heavy'); $this->config->set('HTML.TidyLevel', 'heavy');
} }
protected function getStrategy() { protected function getStrategy() {
@ -26,7 +26,7 @@ class HTMLPurifier_Strategy_RemoveForeignElements_ErrorsTest extends HTMLPurifie
} }
function testForeignElementToText() { function testForeignElementToText() {
$this->config->set('Core', 'EscapeInvalidTags', true); $this->config->set('Core.EscapeInvalidTags', true);
$this->expectErrorCollection(E_WARNING, 'Strategy_RemoveForeignElements: Foreign element to text'); $this->expectErrorCollection(E_WARNING, 'Strategy_RemoveForeignElements: Foreign element to text');
$this->expectContext('CurrentToken', new HTMLPurifier_Token_Start('invalid', array(), 1)); $this->expectContext('CurrentToken', new HTMLPurifier_Token_Start('invalid', array(), 1));
$this->invoke('<invalid>'); $this->invoke('<invalid>');
@ -46,14 +46,14 @@ class HTMLPurifier_Strategy_RemoveForeignElements_ErrorsTest extends HTMLPurifie
} }
function testTrailingHyphenInCommentRemoved() { function testTrailingHyphenInCommentRemoved() {
$this->config->set('HTML', 'Trusted', true); $this->config->set('HTML.Trusted', true);
$this->expectErrorCollection(E_NOTICE, 'Strategy_RemoveForeignElements: Trailing hyphen in comment removed'); $this->expectErrorCollection(E_NOTICE, 'Strategy_RemoveForeignElements: Trailing hyphen in comment removed');
$this->expectContext('CurrentToken', new HTMLPurifier_Token_Comment(' test --', 1)); $this->expectContext('CurrentToken', new HTMLPurifier_Token_Comment(' test --', 1));
$this->invoke('<!-- test ---->'); $this->invoke('<!-- test ---->');
} }
function testDoubleHyphenInCommentRemoved() { function testDoubleHyphenInCommentRemoved() {
$this->config->set('HTML', 'Trusted', true); $this->config->set('HTML.Trusted', true);
$this->expectErrorCollection(E_NOTICE, 'Strategy_RemoveForeignElements: Hyphens in comment collapsed'); $this->expectErrorCollection(E_NOTICE, 'Strategy_RemoveForeignElements: Hyphens in comment collapsed');
$this->expectContext('CurrentToken', new HTMLPurifier_Token_Comment(' test --- test -- test ', 1)); $this->expectContext('CurrentToken', new HTMLPurifier_Token_Comment(' test --- test -- test ', 1));
$this->invoke('<!-- test --- test -- test -->'); $this->invoke('<!-- test --- test -- test -->');

View File

@ -7,7 +7,7 @@ class HTMLPurifier_Strategy_RemoveForeignElements_TidyTest
function setUp() { function setUp() {
parent::setUp(); parent::setUp();
$this->obj = new HTMLPurifier_Strategy_RemoveForeignElements(); $this->obj = new HTMLPurifier_Strategy_RemoveForeignElements();
$this->config->set('HTML', 'TidyLevel', 'heavy'); $this->config->set('HTML.TidyLevel', 'heavy');
} }
function testCenterTransform() { function testCenterTransform() {
@ -26,7 +26,7 @@ class HTMLPurifier_Strategy_RemoveForeignElements_TidyTest
} }
function testTransformToForbiddenElement() { function testTransformToForbiddenElement() {
$this->config->set('HTML', 'Allowed', 'div'); $this->config->set('HTML.Allowed', 'div');
$this->assertResult( $this->assertResult(
'<font color="red" face="Arial" size="6">Big Warning!</font>', '<font color="red" face="Arial" size="6">Big Warning!</font>',
'Big Warning!' 'Big Warning!'

View File

@ -52,7 +52,7 @@ class HTMLPurifier_Strategy_ValidateAttributesTest extends
} }
function testOnlyXMLLangInXHTML11() { function testOnlyXMLLangInXHTML11() {
$this->config->set('HTML', 'Doctype', 'XHTML 1.1'); $this->config->set('HTML.Doctype', 'XHTML 1.1');
$this->assertResult( $this->assertResult(
'<b lang="en">asdf</b>', '<b lang="en">asdf</b>',
'<b xml:lang="en">asdf</b>' '<b xml:lang="en">asdf</b>'
@ -85,7 +85,7 @@ class HTMLPurifier_Strategy_ValidateAttributesTest extends
} }
function testBdoAlternateDefaultDir() { function testBdoAlternateDefaultDir() {
$this->config->set('Attr', 'DefaultTextDir', 'rtl'); $this->config->set('Attr.DefaultTextDir', 'rtl');
$this->assertResult( $this->assertResult(
'<bdo>Go right.</bdo>', '<bdo>Go right.</bdo>',
'<bdo dir="rtl">Go right.</bdo>' '<bdo dir="rtl">Go right.</bdo>'
@ -127,7 +127,7 @@ class HTMLPurifier_Strategy_ValidateAttributesTest extends
} }
function testImgAddDefaults() { function testImgAddDefaults() {
$this->config->set('Core', 'RemoveInvalidImg', false); $this->config->set('Core.RemoveInvalidImg', false);
$this->assertResult( $this->assertResult(
'<img />', '<img />',
'<img src="" alt="Invalid image" />' '<img src="" alt="Invalid image" />'
@ -142,7 +142,7 @@ class HTMLPurifier_Strategy_ValidateAttributesTest extends
} }
function testImgAddDefaultSrc() { function testImgAddDefaultSrc() {
$this->config->set('Core', 'RemoveInvalidImg', false); $this->config->set('Core.RemoveInvalidImg', false);
$this->assertResult( $this->assertResult(
'<img alt="pretty picture" />', '<img alt="pretty picture" />',
'<img alt="pretty picture" src="" />' '<img alt="pretty picture" src="" />'
@ -150,7 +150,7 @@ class HTMLPurifier_Strategy_ValidateAttributesTest extends
} }
function testImgRemoveNonRetrievableProtocol() { function testImgRemoveNonRetrievableProtocol() {
$this->config->set('Core', 'RemoveInvalidImg', false); $this->config->set('Core.RemoveInvalidImg', false);
$this->assertResult( $this->assertResult(
'<img src="mailto:foo@example.com" />', '<img src="mailto:foo@example.com" />',
'<img alt="mailto:foo@example.com" src="" />' '<img alt="mailto:foo@example.com" src="" />'
@ -158,19 +158,19 @@ class HTMLPurifier_Strategy_ValidateAttributesTest extends
} }
function testPreserveRel() { function testPreserveRel() {
$this->config->set('Attr', 'AllowedRel', 'nofollow'); $this->config->set('Attr.AllowedRel', 'nofollow');
$this->assertResult('<a href="foo" rel="nofollow" />'); $this->assertResult('<a href="foo" rel="nofollow" />');
} }
function testPreserveTarget() { function testPreserveTarget() {
$this->config->set('Attr', 'AllowedFrameTargets', '_top'); $this->config->set('Attr.AllowedFrameTargets', '_top');
$this->config->set('HTML', 'Doctype', 'XHTML 1.0 Transitional'); $this->config->set('HTML.Doctype', 'XHTML 1.0 Transitional');
$this->assertResult('<a href="foo" target="_top" />'); $this->assertResult('<a href="foo" target="_top" />');
} }
function testRemoveTargetWhenNotSupported() { function testRemoveTargetWhenNotSupported() {
$this->config->set('HTML', 'Doctype', 'XHTML 1.0 Strict'); $this->config->set('HTML.Doctype', 'XHTML 1.0 Strict');
$this->config->set('Attr', 'AllowedFrameTargets', '_top'); $this->config->set('Attr.AllowedFrameTargets', '_top');
$this->assertResult( $this->assertResult(
'<a href="foo" target="_top" />', '<a href="foo" target="_top" />',
'<a href="foo" />' '<a href="foo" />'
@ -191,7 +191,7 @@ class HTMLPurifier_Strategy_ValidateAttributesTest extends
} }
function testRemoveLargeCSSWidthAndHeightOnImgWithUserConf() { function testRemoveLargeCSSWidthAndHeightOnImgWithUserConf() {
$this->config->set('CSS', 'MaxImgLength', '1px'); $this->config->set('CSS.MaxImgLength', '1px');
$this->assertResult( $this->assertResult(
'<img src="" alt="" style="width:1mm;height:1mm;border:1px solid #000;" />', '<img src="" alt="" style="width:1mm;height:1mm;border:1px solid #000;" />',
'<img src="" alt="" style="border:1px solid #000;" />' '<img src="" alt="" style="border:1px solid #000;" />'
@ -199,14 +199,14 @@ class HTMLPurifier_Strategy_ValidateAttributesTest extends
} }
function testKeepLargeCSSWidthAndHeightOnImgWhenToldTo() { function testKeepLargeCSSWidthAndHeightOnImgWhenToldTo() {
$this->config->set('CSS', 'MaxImgLength', null); $this->config->set('CSS.MaxImgLength', null);
$this->assertResult( $this->assertResult(
'<img src="" alt="" style="width:10000000px;height:10000000px;border:1px solid #000;" />' '<img src="" alt="" style="width:10000000px;height:10000000px;border:1px solid #000;" />'
); );
} }
function testKeepPercentCSSWidthAndHeightOnImgWhenToldTo() { function testKeepPercentCSSWidthAndHeightOnImgWhenToldTo() {
$this->config->set('CSS', 'MaxImgLength', null); $this->config->set('CSS.MaxImgLength', null);
$this->assertResult( $this->assertResult(
'<img src="" alt="" style="width:100%;height:100%;border:1px solid #000;" />' '<img src="" alt="" style="width:100%;height:100%;border:1px solid #000;" />'
); );

View File

@ -6,7 +6,7 @@ class HTMLPurifier_Strategy_ValidateAttributes_IDTest extends HTMLPurifier_Strat
function setUp() { function setUp() {
parent::setUp(); parent::setUp();
$this->obj = new HTMLPurifier_Strategy_ValidateAttributes(); $this->obj = new HTMLPurifier_Strategy_ValidateAttributes();
$this->config->set('Attr', 'EnableID', true); $this->config->set('Attr.EnableID', true);
} }
@ -43,7 +43,7 @@ class HTMLPurifier_Strategy_ValidateAttributes_IDTest extends HTMLPurifier_Strat
} }
function testIDBlacklist() { function testIDBlacklist() {
$this->config->set('Attr', 'IDBlacklist', array('invalid')); $this->config->set('Attr.IDBlacklist', array('invalid'));
$this->assertResult( $this->assertResult(
'<div id="invalid">Invalid</div>', '<div id="invalid">Invalid</div>',
'<div>Invalid</div>' '<div>Invalid</div>'
@ -51,7 +51,7 @@ class HTMLPurifier_Strategy_ValidateAttributes_IDTest extends HTMLPurifier_Strat
} }
function testNameConvertedToID() { function testNameConvertedToID() {
$this->config->set('HTML', 'TidyLevel', 'heavy'); $this->config->set('HTML.TidyLevel', 'heavy');
$this->assertResult( $this->assertResult(
'<a name="foobar" />', '<a name="foobar" />',
'<a id="foobar" />' '<a id="foobar" />'

View File

@ -6,7 +6,7 @@ class HTMLPurifier_Strategy_ValidateAttributes_TidyTest extends HTMLPurifier_Str
function setUp() { function setUp() {
parent::setUp(); parent::setUp();
$this->obj = new HTMLPurifier_Strategy_ValidateAttributes(); $this->obj = new HTMLPurifier_Strategy_ValidateAttributes();
$this->config->set('HTML', 'TidyLevel', 'heavy'); $this->config->set('HTML.TidyLevel', 'heavy');
} }
function testConvertCenterAlign() { function testConvertCenterAlign() {

View File

@ -33,9 +33,9 @@ class HTMLPurifier_URIDefinitionTest extends HTMLPurifier_URIHarness
} }
function test_setupMemberVariables_collisionPrecedenceIsHostBaseScheme() { function test_setupMemberVariables_collisionPrecedenceIsHostBaseScheme() {
$this->config->set('URI', 'Host', $host = 'example.com'); $this->config->set('URI.Host', $host = 'example.com');
$this->config->set('URI', 'Base', $base = 'http://sub.example.com/foo/bar.html'); $this->config->set('URI.Base', $base = 'http://sub.example.com/foo/bar.html');
$this->config->set('URI', 'DefaultScheme', 'ftp'); $this->config->set('URI.DefaultScheme', 'ftp');
$def = new HTMLPurifier_URIDefinition(); $def = new HTMLPurifier_URIDefinition();
$def->setup($this->config); $def->setup($this->config);
$this->assertIdentical($def->host, $host); $this->assertIdentical($def->host, $host);
@ -44,14 +44,14 @@ class HTMLPurifier_URIDefinitionTest extends HTMLPurifier_URIHarness
} }
function test_setupMemberVariables_onlyScheme() { function test_setupMemberVariables_onlyScheme() {
$this->config->set('URI', 'DefaultScheme', 'ftp'); $this->config->set('URI.DefaultScheme', 'ftp');
$def = new HTMLPurifier_URIDefinition(); $def = new HTMLPurifier_URIDefinition();
$def->setup($this->config); $def->setup($this->config);
$this->assertIdentical($def->defaultScheme, 'ftp'); $this->assertIdentical($def->defaultScheme, 'ftp');
} }
function test_setupMemberVariables_onlyBase() { function test_setupMemberVariables_onlyBase() {
$this->config->set('URI', 'Base', 'http://sub.example.com/foo/bar.html'); $this->config->set('URI.Base', 'http://sub.example.com/foo/bar.html');
$def = new HTMLPurifier_URIDefinition(); $def = new HTMLPurifier_URIDefinition();
$def->setup($this->config); $def->setup($this->config);
$this->assertIdentical($def->host, 'sub.example.com'); $this->assertIdentical($def->host, 'sub.example.com');

Some files were not shown because too many files have changed in this diff Show More