aboutsummaryrefslogtreecommitdiffstats
path: root/library/HTMLPurifier/AttrDef.php
diff options
context:
space:
mode:
Diffstat (limited to 'library/HTMLPurifier/AttrDef.php')
-rw-r--r--library/HTMLPurifier/AttrDef.php53
1 files changed, 34 insertions, 19 deletions
diff --git a/library/HTMLPurifier/AttrDef.php b/library/HTMLPurifier/AttrDef.php
index b2e4f36c5..5ac06522b 100644
--- a/library/HTMLPurifier/AttrDef.php
+++ b/library/HTMLPurifier/AttrDef.php
@@ -14,23 +14,25 @@ abstract class HTMLPurifier_AttrDef
{
/**
- * Tells us whether or not an HTML attribute is minimized. Has no
- * meaning in other contexts.
+ * Tells us whether or not an HTML attribute is minimized.
+ * Has no meaning in other contexts.
+ * @type bool
*/
public $minimized = false;
/**
- * Tells us whether or not an HTML attribute is required. Has no
- * meaning in other contexts
+ * Tells us whether or not an HTML attribute is required.
+ * Has no meaning in other contexts
+ * @type bool
*/
public $required = false;
/**
* Validates and cleans passed string according to a definition.
*
- * @param $string String to be validated and cleaned.
- * @param $config Mandatory HTMLPurifier_Config object.
- * @param $context Mandatory HTMLPurifier_AttrContext object.
+ * @param string $string String to be validated and cleaned.
+ * @param HTMLPurifier_Config $config Mandatory HTMLPurifier_Config object.
+ * @param HTMLPurifier_Context $context Mandatory HTMLPurifier_Context object.
*/
abstract public function validate($string, $config, $context);
@@ -55,7 +57,8 @@ abstract class HTMLPurifier_AttrDef
* parsing XML, thus, this behavior may still be correct. We
* assume that newlines have been normalized.
*/
- public function parseCDATA($string) {
+ public function parseCDATA($string)
+ {
$string = trim($string);
$string = str_replace(array("\n", "\t", "\r"), ' ', $string);
return $string;
@@ -63,10 +66,11 @@ abstract class HTMLPurifier_AttrDef
/**
* Factory method for creating this class from a string.
- * @param $string String construction info
- * @return Created AttrDef object corresponding to $string
+ * @param string $string String construction info
+ * @return HTMLPurifier_AttrDef Created AttrDef object corresponding to $string
*/
- public function make($string) {
+ public function make($string)
+ {
// default implementation, return a flyweight of this object.
// If $string has an effect on the returned object (i.e. you
// need to overload this method), it is best
@@ -77,16 +81,20 @@ abstract class HTMLPurifier_AttrDef
/**
* Removes spaces from rgb(0, 0, 0) so that shorthand CSS properties work
* properly. THIS IS A HACK!
+ * @param string $string a CSS colour definition
+ * @return string
*/
- protected function mungeRgb($string) {
+ protected function mungeRgb($string)
+ {
return preg_replace('/rgb\((\d+)\s*,\s*(\d+)\s*,\s*(\d+)\)/', 'rgb(\1,\2,\3)', $string);
}
/**
- * Parses a possibly escaped CSS string and returns the "pure"
+ * Parses a possibly escaped CSS string and returns the "pure"
* version of it.
*/
- protected function expandCSSEscape($string) {
+ protected function expandCSSEscape($string)
+ {
// flexibly parse it
$ret = '';
for ($i = 0, $c = strlen($string); $i < $c; $i++) {
@@ -99,25 +107,32 @@ abstract class HTMLPurifier_AttrDef
if (ctype_xdigit($string[$i])) {
$code = $string[$i];
for ($a = 1, $i++; $i < $c && $a < 6; $i++, $a++) {
- if (!ctype_xdigit($string[$i])) break;
+ if (!ctype_xdigit($string[$i])) {
+ break;
+ }
$code .= $string[$i];
}
// We have to be extremely careful when adding
// new characters, to make sure we're not breaking
// the encoding.
$char = HTMLPurifier_Encoder::unichr(hexdec($code));
- if (HTMLPurifier_Encoder::cleanUTF8($char) === '') continue;
+ if (HTMLPurifier_Encoder::cleanUTF8($char) === '') {
+ continue;
+ }
$ret .= $char;
- if ($i < $c && trim($string[$i]) !== '') $i--;
+ if ($i < $c && trim($string[$i]) !== '') {
+ $i--;
+ }
+ continue;
+ }
+ if ($string[$i] === "\n") {
continue;
}
- if ($string[$i] === "\n") continue;
}
$ret .= $string[$i];
}
return $ret;
}
-
}
// vim: et sw=4 sts=4