From 92913bc8165eb35593f31fd2dd21f11409df8f78 Mon Sep 17 00:00:00 2001 From: "Edward Z. Yang" Date: Sat, 4 Sep 2010 02:26:25 -0400 Subject: [PATCH] Add documentation about configuration directive types. Signed-off-by: Edward Z. Yang --- NEWS | 1 + configdoc/styles/plain.xsl | 25 +++++++-- configdoc/types.xml | 86 +++++++++++++++++++++++------ library/HTMLPurifier/VarParser/Flexible.php | 9 ++- 4 files changed, 99 insertions(+), 22 deletions(-) rewrite configdoc/types.xml (82%) diff --git a/NEWS b/NEWS index 2a32d009..2aadbd02 100644 --- a/NEWS +++ b/NEWS @@ -14,6 +14,7 @@ NEWS ( CHANGELOG and HISTORY ) HTMLPurifier statements. ! Added %URI.DisableResources functionality; the directive originally did nothing. Thanks David Rothstein for reporting. +! Add documentation about configuration directive types. - Fix improper handling of Internet Explorer conditional comments by parser. Thanks zmonteca for reporting. - Fix missing attributes bug when running on Mac Snow Leopard and APC. diff --git a/configdoc/styles/plain.xsl b/configdoc/styles/plain.xsl index 07fb5fcd..9b9794e0 100644 --- a/configdoc/styles/plain.xsl +++ b/configdoc/styles/plain.xsl @@ -40,12 +40,26 @@ +
+

Types

+ +
+ +
+ type- +

:

+
+ +
+
+
+ @@ -192,10 +206,13 @@ type type- - - - (or null) - + + #type- + + + (or null) + + diff --git a/configdoc/types.xml b/configdoc/types.xml dissimilarity index 82% index 3e3ee388..ee2c945a 100644 --- a/configdoc/types.xml +++ b/configdoc/types.xml @@ -1,17 +1,69 @@ - - - String - Case-insensitive string - Text - Case-insensitive text - Integer - Float - Boolean - Lookup array - Array list - Associative array - Mixed - - - + + + +
+ A series of case-insensitive characters. Internally, upper-case + ASCII characters will be converted to lower-case. +
+
+ A series of characters that may contain newlines. Text tends to + indicate human-oriented text, as opposed to a machine format. +
+
+ A series of case-insensitive characters that may contain newlines. +
+
+ An + integer. You are alternatively permitted to pass a string of + digits instead, which will be cast to an integer using + (int). +
+
+ A + floating point number. You are alternatively permitted to + pass a numeric string (as defined by is_numeric()), + which will be cast to a float using (float). +
+
+ A boolean. + You are alternatively permitted to pass an integer 0 or + 1 (other integers are not permitted) or a string + "on", "true" or "1" for + true, and "off", "false" or + "0" for false. +
+
+ An array whose values are true, e.g. array('key' + => true, 'key2' => true). You are alternatively permitted + to pass an array list of the keys array('key', 'key2') + or a comma-separated string of keys "key, key2". If + you pass an array list of values, ensure that your values are + strictly numerically indexed: array('key1', 2 => + 'key2') will not do what you expect and emits a warning. +
+
+ An array which has consecutive integer indexes, e.g. + array('val1', 'val2'). You are alternatively permitted + to pass a comma-separated string of keys "val1, val2". + If your array is not in this form, array_values is run + on the array and a warning is emitted. +
+
+ An array which is a mapping of keys to values, e.g. + array('key1' => 'val1', 'key2' => 'val2'). You are + alternatively permitted to pass a comma-separated string of + key-colon-value strings, e.g. "key1: val1, key2: val2". +
+
+ An arbitrary PHP value of any type. +
+
+ + diff --git a/library/HTMLPurifier/VarParser/Flexible.php b/library/HTMLPurifier/VarParser/Flexible.php index c954250e..21b87675 100644 --- a/library/HTMLPurifier/VarParser/Flexible.php +++ b/library/HTMLPurifier/VarParser/Flexible.php @@ -62,7 +62,7 @@ class HTMLPurifier_VarParser_Flexible extends HTMLPurifier_VarParser foreach ($var as $keypair) { $c = explode(':', $keypair, 2); if (!isset($c[1])) continue; - $nvar[$c[0]] = $c[1]; + $nvar[trim($c[0])] = trim($c[1]); } $var = $nvar; } @@ -79,8 +79,15 @@ class HTMLPurifier_VarParser_Flexible extends HTMLPurifier_VarParser return $new; } else break; } + if ($type === self::ALIST) { + trigger_error("Array list did not have consecutive integer indexes", E_USER_WARNING); + return array_values($var); + } if ($type === self::LOOKUP) { foreach ($var as $key => $value) { + if ($value !== true) { + trigger_error("Lookup array has non-true value at key '$key'; maybe your input array was not indexed numerically", E_USER_WARNING); + } $var[$key] = true; } } -- 2.11.4.GIT