GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Push — master ( b130b6...8a2f54 )
by gyeong-won
07:36
created
classes/security/htmlpurifier/library/HTMLPurifier.func.php 1 patch
Indentation   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -13,11 +13,11 @@
 block discarded – undo
13 13
  *        HTMLPurifier_Config::create()
14 14
  */
15 15
 function HTMLPurifier($html, $config = null) {
16
-    static $purifier = false;
17
-    if (!$purifier) {
18
-        $purifier = new HTMLPurifier();
19
-    }
20
-    return $purifier->purify($html, $config);
16
+	static $purifier = false;
17
+	if (!$purifier) {
18
+		$purifier = new HTMLPurifier();
19
+	}
20
+	return $purifier->purify($html, $config);
21 21
 }
22 22
 
23 23
 // vim: et sw=4 sts=4
Please login to merge, or discard this patch.
classes/security/htmlpurifier/library/HTMLPurifier.kses.php 2 patches
Indentation   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -8,23 +8,23 @@
 block discarded – undo
8 8
 require_once dirname(__FILE__) . '/HTMLPurifier.auto.php';
9 9
 
10 10
 function kses($string, $allowed_html, $allowed_protocols = null) {
11
-    $config = HTMLPurifier_Config::createDefault();
12
-    $allowed_elements = array();
13
-    $allowed_attributes = array();
14
-    foreach ($allowed_html as $element => $attributes) {
15
-        $allowed_elements[$element] = true;
16
-        foreach ($attributes as $attribute => $x) {
17
-            $allowed_attributes["$element.$attribute"] = true;
18
-        }
19
-    }
20
-    $config->set('HTML.AllowedElements', $allowed_elements);
21
-    $config->set('HTML.AllowedAttributes', $allowed_attributes);
22
-    $allowed_schemes = array();
23
-    if ($allowed_protocols !== null) {
24
-        $config->set('URI.AllowedSchemes', $allowed_protocols);
25
-    }
26
-    $purifier = new HTMLPurifier($config);
27
-    return $purifier->purify($string);
11
+	$config = HTMLPurifier_Config::createDefault();
12
+	$allowed_elements = array();
13
+	$allowed_attributes = array();
14
+	foreach ($allowed_html as $element => $attributes) {
15
+		$allowed_elements[$element] = true;
16
+		foreach ($attributes as $attribute => $x) {
17
+			$allowed_attributes["$element.$attribute"] = true;
18
+		}
19
+	}
20
+	$config->set('HTML.AllowedElements', $allowed_elements);
21
+	$config->set('HTML.AllowedAttributes', $allowed_attributes);
22
+	$allowed_schemes = array();
23
+	if ($allowed_protocols !== null) {
24
+		$config->set('URI.AllowedSchemes', $allowed_protocols);
25
+	}
26
+	$purifier = new HTMLPurifier($config);
27
+	return $purifier->purify($string);
28 28
 }
29 29
 
30 30
 // vim: et sw=4 sts=4
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -5,7 +5,7 @@
 block discarded – undo
5 5
  * Emulation layer for code that used kses(), substituting in HTML Purifier.
6 6
  */
7 7
 
8
-require_once dirname(__FILE__) . '/HTMLPurifier.auto.php';
8
+require_once dirname(__FILE__).'/HTMLPurifier.auto.php';
9 9
 
10 10
 function kses($string, $allowed_html, $allowed_protocols = null) {
11 11
     $config = HTMLPurifier_Config::createDefault();
Please login to merge, or discard this patch.
classes/security/htmlpurifier/library/HTMLPurifier.php 3 patches
Indentation   +177 added lines, -177 removed lines patch added patch discarded remove patch
@@ -54,183 +54,183 @@
 block discarded – undo
54 54
 class HTMLPurifier
55 55
 {
56 56
 
57
-    /** Version of HTML Purifier */
58
-    public $version = '4.4.0';
59
-
60
-    /** Constant with version of HTML Purifier */
61
-    const VERSION = '4.4.0';
62
-
63
-    /** Global configuration object */
64
-    public $config;
65
-
66
-    /** Array of extra HTMLPurifier_Filter objects to run on HTML, for backwards compatibility */
67
-    private $filters = array();
68
-
69
-    /** Single instance of HTML Purifier */
70
-    private static $instance;
71
-
72
-    protected $strategy, $generator;
73
-
74
-    /**
75
-     * Resultant HTMLPurifier_Context of last run purification. Is an array
76
-     * of contexts if the last called method was purifyArray().
77
-     */
78
-    public $context;
79
-
80
-    /**
81
-     * Initializes the purifier.
82
-     * @param $config Optional HTMLPurifier_Config object for all instances of
83
-     *                the purifier, if omitted, a default configuration is
84
-     *                supplied (which can be overridden on a per-use basis).
85
-     *                The parameter can also be any type that
86
-     *                HTMLPurifier_Config::create() supports.
87
-     */
88
-    public function __construct($config = null) {
89
-
90
-        $this->config = HTMLPurifier_Config::create($config);
91
-
92
-        $this->strategy     = new HTMLPurifier_Strategy_Core();
93
-
94
-    }
95
-
96
-    /**
97
-     * Adds a filter to process the output. First come first serve
98
-     * @param $filter HTMLPurifier_Filter object
99
-     */
100
-    public function addFilter($filter) {
101
-        trigger_error('HTMLPurifier->addFilter() is deprecated, use configuration directives in the Filter namespace or Filter.Custom', E_USER_WARNING);
102
-        $this->filters[] = $filter;
103
-    }
104
-
105
-    /**
106
-     * Filters an HTML snippet/document to be XSS-free and standards-compliant.
107
-     *
108
-     * @param $html String of HTML to purify
109
-     * @param $config HTMLPurifier_Config object for this operation, if omitted,
110
-     *                defaults to the config object specified during this
111
-     *                object's construction. The parameter can also be any type
112
-     *                that HTMLPurifier_Config::create() supports.
113
-     * @return Purified HTML
114
-     */
115
-    public function purify($html, $config = null) {
116
-
117
-        // :TODO: make the config merge in, instead of replace
118
-        $config = $config ? HTMLPurifier_Config::create($config) : $this->config;
119
-
120
-        // implementation is partially environment dependant, partially
121
-        // configuration dependant
122
-        $lexer = HTMLPurifier_Lexer::create($config);
123
-
124
-        $context = new HTMLPurifier_Context();
125
-
126
-        // setup HTML generator
127
-        $this->generator = new HTMLPurifier_Generator($config, $context);
128
-        $context->register('Generator', $this->generator);
129
-
130
-        // set up global context variables
131
-        if ($config->get('Core.CollectErrors')) {
132
-            // may get moved out if other facilities use it
133
-            $language_factory = HTMLPurifier_LanguageFactory::instance();
134
-            $language = $language_factory->create($config, $context);
135
-            $context->register('Locale', $language);
136
-
137
-            $error_collector = new HTMLPurifier_ErrorCollector($context);
138
-            $context->register('ErrorCollector', $error_collector);
139
-        }
140
-
141
-        // setup id_accumulator context, necessary due to the fact that
142
-        // AttrValidator can be called from many places
143
-        $id_accumulator = HTMLPurifier_IDAccumulator::build($config, $context);
144
-        $context->register('IDAccumulator', $id_accumulator);
145
-
146
-        $html = HTMLPurifier_Encoder::convertToUTF8($html, $config, $context);
147
-
148
-        // setup filters
149
-        $filter_flags = $config->getBatch('Filter');
150
-        $custom_filters = $filter_flags['Custom'];
151
-        unset($filter_flags['Custom']);
152
-        $filters = array();
153
-        foreach ($filter_flags as $filter => $flag) {
154
-            if (!$flag) continue;
155
-            if (strpos($filter, '.') !== false) continue;
156
-            $class = "HTMLPurifier_Filter_$filter";
157
-            $filters[] = new $class;
158
-        }
159
-        foreach ($custom_filters as $filter) {
160
-            // maybe "HTMLPurifier_Filter_$filter", but be consistent with AutoFormat
161
-            $filters[] = $filter;
162
-        }
163
-        $filters = array_merge($filters, $this->filters);
164
-        // maybe prepare(), but later
165
-
166
-        for ($i = 0, $filter_size = count($filters); $i < $filter_size; $i++) {
167
-            $html = $filters[$i]->preFilter($html, $config, $context);
168
-        }
169
-
170
-        // purified HTML
171
-        $html =
172
-            $this->generator->generateFromTokens(
173
-                // list of tokens
174
-                $this->strategy->execute(
175
-                    // list of un-purified tokens
176
-                    $lexer->tokenizeHTML(
177
-                        // un-purified HTML
178
-                        $html, $config, $context
179
-                    ),
180
-                    $config, $context
181
-                )
182
-            );
183
-
184
-        for ($i = $filter_size - 1; $i >= 0; $i--) {
185
-            $html = $filters[$i]->postFilter($html, $config, $context);
186
-        }
187
-
188
-        $html = HTMLPurifier_Encoder::convertFromUTF8($html, $config, $context);
189
-        $this->context =& $context;
190
-        return $html;
191
-    }
192
-
193
-    /**
194
-     * Filters an array of HTML snippets
195
-     * @param $config Optional HTMLPurifier_Config object for this operation.
196
-     *                See HTMLPurifier::purify() for more details.
197
-     * @return Array of purified HTML
198
-     */
199
-    public function purifyArray($array_of_html, $config = null) {
200
-        $context_array = array();
201
-        foreach ($array_of_html as $key => $html) {
202
-            $array_of_html[$key] = $this->purify($html, $config);
203
-            $context_array[$key] = $this->context;
204
-        }
205
-        $this->context = $context_array;
206
-        return $array_of_html;
207
-    }
208
-
209
-    /**
210
-     * Singleton for enforcing just one HTML Purifier in your system
211
-     * @param $prototype Optional prototype HTMLPurifier instance to
212
-     *                   overload singleton with, or HTMLPurifier_Config
213
-     *                   instance to configure the generated version with.
214
-     */
215
-    public static function instance($prototype = null) {
216
-        if (!self::$instance || $prototype) {
217
-            if ($prototype instanceof HTMLPurifier) {
218
-                self::$instance = $prototype;
219
-            } elseif ($prototype) {
220
-                self::$instance = new HTMLPurifier($prototype);
221
-            } else {
222
-                self::$instance = new HTMLPurifier();
223
-            }
224
-        }
225
-        return self::$instance;
226
-    }
227
-
228
-    /**
229
-     * @note Backwards compatibility, see instance()
230
-     */
231
-    public static function getInstance($prototype = null) {
232
-        return HTMLPurifier::instance($prototype);
233
-    }
57
+	/** Version of HTML Purifier */
58
+	public $version = '4.4.0';
59
+
60
+	/** Constant with version of HTML Purifier */
61
+	const VERSION = '4.4.0';
62
+
63
+	/** Global configuration object */
64
+	public $config;
65
+
66
+	/** Array of extra HTMLPurifier_Filter objects to run on HTML, for backwards compatibility */
67
+	private $filters = array();
68
+
69
+	/** Single instance of HTML Purifier */
70
+	private static $instance;
71
+
72
+	protected $strategy, $generator;
73
+
74
+	/**
75
+	 * Resultant HTMLPurifier_Context of last run purification. Is an array
76
+	 * of contexts if the last called method was purifyArray().
77
+	 */
78
+	public $context;
79
+
80
+	/**
81
+	 * Initializes the purifier.
82
+	 * @param $config Optional HTMLPurifier_Config object for all instances of
83
+	 *                the purifier, if omitted, a default configuration is
84
+	 *                supplied (which can be overridden on a per-use basis).
85
+	 *                The parameter can also be any type that
86
+	 *                HTMLPurifier_Config::create() supports.
87
+	 */
88
+	public function __construct($config = null) {
89
+
90
+		$this->config = HTMLPurifier_Config::create($config);
91
+
92
+		$this->strategy     = new HTMLPurifier_Strategy_Core();
93
+
94
+	}
95
+
96
+	/**
97
+	 * Adds a filter to process the output. First come first serve
98
+	 * @param $filter HTMLPurifier_Filter object
99
+	 */
100
+	public function addFilter($filter) {
101
+		trigger_error('HTMLPurifier->addFilter() is deprecated, use configuration directives in the Filter namespace or Filter.Custom', E_USER_WARNING);
102
+		$this->filters[] = $filter;
103
+	}
104
+
105
+	/**
106
+	 * Filters an HTML snippet/document to be XSS-free and standards-compliant.
107
+	 *
108
+	 * @param $html String of HTML to purify
109
+	 * @param $config HTMLPurifier_Config object for this operation, if omitted,
110
+	 *                defaults to the config object specified during this
111
+	 *                object's construction. The parameter can also be any type
112
+	 *                that HTMLPurifier_Config::create() supports.
113
+	 * @return Purified HTML
114
+	 */
115
+	public function purify($html, $config = null) {
116
+
117
+		// :TODO: make the config merge in, instead of replace
118
+		$config = $config ? HTMLPurifier_Config::create($config) : $this->config;
119
+
120
+		// implementation is partially environment dependant, partially
121
+		// configuration dependant
122
+		$lexer = HTMLPurifier_Lexer::create($config);
123
+
124
+		$context = new HTMLPurifier_Context();
125
+
126
+		// setup HTML generator
127
+		$this->generator = new HTMLPurifier_Generator($config, $context);
128
+		$context->register('Generator', $this->generator);
129
+
130
+		// set up global context variables
131
+		if ($config->get('Core.CollectErrors')) {
132
+			// may get moved out if other facilities use it
133
+			$language_factory = HTMLPurifier_LanguageFactory::instance();
134
+			$language = $language_factory->create($config, $context);
135
+			$context->register('Locale', $language);
136
+
137
+			$error_collector = new HTMLPurifier_ErrorCollector($context);
138
+			$context->register('ErrorCollector', $error_collector);
139
+		}
140
+
141
+		// setup id_accumulator context, necessary due to the fact that
142
+		// AttrValidator can be called from many places
143
+		$id_accumulator = HTMLPurifier_IDAccumulator::build($config, $context);
144
+		$context->register('IDAccumulator', $id_accumulator);
145
+
146
+		$html = HTMLPurifier_Encoder::convertToUTF8($html, $config, $context);
147
+
148
+		// setup filters
149
+		$filter_flags = $config->getBatch('Filter');
150
+		$custom_filters = $filter_flags['Custom'];
151
+		unset($filter_flags['Custom']);
152
+		$filters = array();
153
+		foreach ($filter_flags as $filter => $flag) {
154
+			if (!$flag) continue;
155
+			if (strpos($filter, '.') !== false) continue;
156
+			$class = "HTMLPurifier_Filter_$filter";
157
+			$filters[] = new $class;
158
+		}
159
+		foreach ($custom_filters as $filter) {
160
+			// maybe "HTMLPurifier_Filter_$filter", but be consistent with AutoFormat
161
+			$filters[] = $filter;
162
+		}
163
+		$filters = array_merge($filters, $this->filters);
164
+		// maybe prepare(), but later
165
+
166
+		for ($i = 0, $filter_size = count($filters); $i < $filter_size; $i++) {
167
+			$html = $filters[$i]->preFilter($html, $config, $context);
168
+		}
169
+
170
+		// purified HTML
171
+		$html =
172
+			$this->generator->generateFromTokens(
173
+				// list of tokens
174
+				$this->strategy->execute(
175
+					// list of un-purified tokens
176
+					$lexer->tokenizeHTML(
177
+						// un-purified HTML
178
+						$html, $config, $context
179
+					),
180
+					$config, $context
181
+				)
182
+			);
183
+
184
+		for ($i = $filter_size - 1; $i >= 0; $i--) {
185
+			$html = $filters[$i]->postFilter($html, $config, $context);
186
+		}
187
+
188
+		$html = HTMLPurifier_Encoder::convertFromUTF8($html, $config, $context);
189
+		$this->context =& $context;
190
+		return $html;
191
+	}
192
+
193
+	/**
194
+	 * Filters an array of HTML snippets
195
+	 * @param $config Optional HTMLPurifier_Config object for this operation.
196
+	 *                See HTMLPurifier::purify() for more details.
197
+	 * @return Array of purified HTML
198
+	 */
199
+	public function purifyArray($array_of_html, $config = null) {
200
+		$context_array = array();
201
+		foreach ($array_of_html as $key => $html) {
202
+			$array_of_html[$key] = $this->purify($html, $config);
203
+			$context_array[$key] = $this->context;
204
+		}
205
+		$this->context = $context_array;
206
+		return $array_of_html;
207
+	}
208
+
209
+	/**
210
+	 * Singleton for enforcing just one HTML Purifier in your system
211
+	 * @param $prototype Optional prototype HTMLPurifier instance to
212
+	 *                   overload singleton with, or HTMLPurifier_Config
213
+	 *                   instance to configure the generated version with.
214
+	 */
215
+	public static function instance($prototype = null) {
216
+		if (!self::$instance || $prototype) {
217
+			if ($prototype instanceof HTMLPurifier) {
218
+				self::$instance = $prototype;
219
+			} elseif ($prototype) {
220
+				self::$instance = new HTMLPurifier($prototype);
221
+			} else {
222
+				self::$instance = new HTMLPurifier();
223
+			}
224
+		}
225
+		return self::$instance;
226
+	}
227
+
228
+	/**
229
+	 * @note Backwards compatibility, see instance()
230
+	 */
231
+	public static function getInstance($prototype = null) {
232
+		return HTMLPurifier::instance($prototype);
233
+	}
234 234
 
235 235
 }
236 236
 
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -89,7 +89,7 @@  discard block
 block discarded – undo
89 89
 
90 90
         $this->config = HTMLPurifier_Config::create($config);
91 91
 
92
-        $this->strategy     = new HTMLPurifier_Strategy_Core();
92
+        $this->strategy = new HTMLPurifier_Strategy_Core();
93 93
 
94 94
     }
95 95
 
@@ -186,7 +186,7 @@  discard block
 block discarded – undo
186 186
         }
187 187
 
188 188
         $html = HTMLPurifier_Encoder::convertFromUTF8($html, $config, $context);
189
-        $this->context =& $context;
189
+        $this->context = & $context;
190 190
         return $html;
191 191
     }
192 192
 
Please login to merge, or discard this patch.
Braces   +6 added lines, -2 removed lines patch added patch discarded remove patch
@@ -151,8 +151,12 @@
 block discarded – undo
151 151
         unset($filter_flags['Custom']);
152 152
         $filters = array();
153 153
         foreach ($filter_flags as $filter => $flag) {
154
-            if (!$flag) continue;
155
-            if (strpos($filter, '.') !== false) continue;
154
+            if (!$flag) {
155
+            	continue;
156
+            }
157
+            if (strpos($filter, '.') !== false) {
158
+            	continue;
159
+            }
156 160
             $class = "HTMLPurifier_Filter_$filter";
157 161
             $filters[] = new $class;
158 162
         }
Please login to merge, or discard this patch.
classes/security/htmlpurifier/library/HTMLPurifier/AttrCollections.php 2 patches
Indentation   +115 added lines, -115 removed lines patch added patch discarded remove patch
@@ -7,121 +7,121 @@
 block discarded – undo
7 7
 class HTMLPurifier_AttrCollections
8 8
 {
9 9
 
10
-    /**
11
-     * Associative array of attribute collections, indexed by name
12
-     */
13
-    public $info = array();
14
-
15
-    /**
16
-     * Performs all expansions on internal data for use by other inclusions
17
-     * It also collects all attribute collection extensions from
18
-     * modules
19
-     * @param $attr_types HTMLPurifier_AttrTypes instance
20
-     * @param $modules Hash array of HTMLPurifier_HTMLModule members
21
-     */
22
-    public function __construct($attr_types, $modules) {
23
-        // load extensions from the modules
24
-        foreach ($modules as $module) {
25
-            foreach ($module->attr_collections as $coll_i => $coll) {
26
-                if (!isset($this->info[$coll_i])) {
27
-                    $this->info[$coll_i] = array();
28
-                }
29
-                foreach ($coll as $attr_i => $attr) {
30
-                    if ($attr_i === 0 && isset($this->info[$coll_i][$attr_i])) {
31
-                        // merge in includes
32
-                        $this->info[$coll_i][$attr_i] = array_merge(
33
-                            $this->info[$coll_i][$attr_i], $attr);
34
-                        continue;
35
-                    }
36
-                    $this->info[$coll_i][$attr_i] = $attr;
37
-                }
38
-            }
39
-        }
40
-        // perform internal expansions and inclusions
41
-        foreach ($this->info as $name => $attr) {
42
-            // merge attribute collections that include others
43
-            $this->performInclusions($this->info[$name]);
44
-            // replace string identifiers with actual attribute objects
45
-            $this->expandIdentifiers($this->info[$name], $attr_types);
46
-        }
47
-    }
48
-
49
-    /**
50
-     * Takes a reference to an attribute associative array and performs
51
-     * all inclusions specified by the zero index.
52
-     * @param &$attr Reference to attribute array
53
-     */
54
-    public function performInclusions(&$attr) {
55
-        if (!isset($attr[0])) return;
56
-        $merge = $attr[0];
57
-        $seen  = array(); // recursion guard
58
-        // loop through all the inclusions
59
-        for ($i = 0; isset($merge[$i]); $i++) {
60
-            if (isset($seen[$merge[$i]])) continue;
61
-            $seen[$merge[$i]] = true;
62
-            // foreach attribute of the inclusion, copy it over
63
-            if (!isset($this->info[$merge[$i]])) continue;
64
-            foreach ($this->info[$merge[$i]] as $key => $value) {
65
-                if (isset($attr[$key])) continue; // also catches more inclusions
66
-                $attr[$key] = $value;
67
-            }
68
-            if (isset($this->info[$merge[$i]][0])) {
69
-                // recursion
70
-                $merge = array_merge($merge, $this->info[$merge[$i]][0]);
71
-            }
72
-        }
73
-        unset($attr[0]);
74
-    }
75
-
76
-    /**
77
-     * Expands all string identifiers in an attribute array by replacing
78
-     * them with the appropriate values inside HTMLPurifier_AttrTypes
79
-     * @param &$attr Reference to attribute array
80
-     * @param $attr_types HTMLPurifier_AttrTypes instance
81
-     */
82
-    public function expandIdentifiers(&$attr, $attr_types) {
83
-
84
-        // because foreach will process new elements we add, make sure we
85
-        // skip duplicates
86
-        $processed = array();
87
-
88
-        foreach ($attr as $def_i => $def) {
89
-            // skip inclusions
90
-            if ($def_i === 0) continue;
91
-
92
-            if (isset($processed[$def_i])) continue;
93
-
94
-            // determine whether or not attribute is required
95
-            if ($required = (strpos($def_i, '*') !== false)) {
96
-                // rename the definition
97
-                unset($attr[$def_i]);
98
-                $def_i = trim($def_i, '*');
99
-                $attr[$def_i] = $def;
100
-            }
101
-
102
-            $processed[$def_i] = true;
103
-
104
-            // if we've already got a literal object, move on
105
-            if (is_object($def)) {
106
-                // preserve previous required
107
-                $attr[$def_i]->required = ($required || $attr[$def_i]->required);
108
-                continue;
109
-            }
110
-
111
-            if ($def === false) {
112
-                unset($attr[$def_i]);
113
-                continue;
114
-            }
115
-
116
-            if ($t = $attr_types->get($def)) {
117
-                $attr[$def_i] = $t;
118
-                $attr[$def_i]->required = $required;
119
-            } else {
120
-                unset($attr[$def_i]);
121
-            }
122
-        }
123
-
124
-    }
10
+	/**
11
+	 * Associative array of attribute collections, indexed by name
12
+	 */
13
+	public $info = array();
14
+
15
+	/**
16
+	 * Performs all expansions on internal data for use by other inclusions
17
+	 * It also collects all attribute collection extensions from
18
+	 * modules
19
+	 * @param $attr_types HTMLPurifier_AttrTypes instance
20
+	 * @param $modules Hash array of HTMLPurifier_HTMLModule members
21
+	 */
22
+	public function __construct($attr_types, $modules) {
23
+		// load extensions from the modules
24
+		foreach ($modules as $module) {
25
+			foreach ($module->attr_collections as $coll_i => $coll) {
26
+				if (!isset($this->info[$coll_i])) {
27
+					$this->info[$coll_i] = array();
28
+				}
29
+				foreach ($coll as $attr_i => $attr) {
30
+					if ($attr_i === 0 && isset($this->info[$coll_i][$attr_i])) {
31
+						// merge in includes
32
+						$this->info[$coll_i][$attr_i] = array_merge(
33
+							$this->info[$coll_i][$attr_i], $attr);
34
+						continue;
35
+					}
36
+					$this->info[$coll_i][$attr_i] = $attr;
37
+				}
38
+			}
39
+		}
40
+		// perform internal expansions and inclusions
41
+		foreach ($this->info as $name => $attr) {
42
+			// merge attribute collections that include others
43
+			$this->performInclusions($this->info[$name]);
44
+			// replace string identifiers with actual attribute objects
45
+			$this->expandIdentifiers($this->info[$name], $attr_types);
46
+		}
47
+	}
48
+
49
+	/**
50
+	 * Takes a reference to an attribute associative array and performs
51
+	 * all inclusions specified by the zero index.
52
+	 * @param &$attr Reference to attribute array
53
+	 */
54
+	public function performInclusions(&$attr) {
55
+		if (!isset($attr[0])) return;
56
+		$merge = $attr[0];
57
+		$seen  = array(); // recursion guard
58
+		// loop through all the inclusions
59
+		for ($i = 0; isset($merge[$i]); $i++) {
60
+			if (isset($seen[$merge[$i]])) continue;
61
+			$seen[$merge[$i]] = true;
62
+			// foreach attribute of the inclusion, copy it over
63
+			if (!isset($this->info[$merge[$i]])) continue;
64
+			foreach ($this->info[$merge[$i]] as $key => $value) {
65
+				if (isset($attr[$key])) continue; // also catches more inclusions
66
+				$attr[$key] = $value;
67
+			}
68
+			if (isset($this->info[$merge[$i]][0])) {
69
+				// recursion
70
+				$merge = array_merge($merge, $this->info[$merge[$i]][0]);
71
+			}
72
+		}
73
+		unset($attr[0]);
74
+	}
75
+
76
+	/**
77
+	 * Expands all string identifiers in an attribute array by replacing
78
+	 * them with the appropriate values inside HTMLPurifier_AttrTypes
79
+	 * @param &$attr Reference to attribute array
80
+	 * @param $attr_types HTMLPurifier_AttrTypes instance
81
+	 */
82
+	public function expandIdentifiers(&$attr, $attr_types) {
83
+
84
+		// because foreach will process new elements we add, make sure we
85
+		// skip duplicates
86
+		$processed = array();
87
+
88
+		foreach ($attr as $def_i => $def) {
89
+			// skip inclusions
90
+			if ($def_i === 0) continue;
91
+
92
+			if (isset($processed[$def_i])) continue;
93
+
94
+			// determine whether or not attribute is required
95
+			if ($required = (strpos($def_i, '*') !== false)) {
96
+				// rename the definition
97
+				unset($attr[$def_i]);
98
+				$def_i = trim($def_i, '*');
99
+				$attr[$def_i] = $def;
100
+			}
101
+
102
+			$processed[$def_i] = true;
103
+
104
+			// if we've already got a literal object, move on
105
+			if (is_object($def)) {
106
+				// preserve previous required
107
+				$attr[$def_i]->required = ($required || $attr[$def_i]->required);
108
+				continue;
109
+			}
110
+
111
+			if ($def === false) {
112
+				unset($attr[$def_i]);
113
+				continue;
114
+			}
115
+
116
+			if ($t = $attr_types->get($def)) {
117
+				$attr[$def_i] = $t;
118
+				$attr[$def_i]->required = $required;
119
+			} else {
120
+				unset($attr[$def_i]);
121
+			}
122
+		}
123
+
124
+	}
125 125
 
126 126
 }
127 127
 
Please login to merge, or discard this patch.
Braces   +19 added lines, -6 removed lines patch added patch discarded remove patch
@@ -52,17 +52,26 @@  discard block
 block discarded – undo
52 52
      * @param &$attr Reference to attribute array
53 53
      */
54 54
     public function performInclusions(&$attr) {
55
-        if (!isset($attr[0])) return;
55
+        if (!isset($attr[0])) {
56
+        	return;
57
+        }
56 58
         $merge = $attr[0];
57 59
         $seen  = array(); // recursion guard
58 60
         // loop through all the inclusions
59 61
         for ($i = 0; isset($merge[$i]); $i++) {
60
-            if (isset($seen[$merge[$i]])) continue;
62
+            if (isset($seen[$merge[$i]])) {
63
+            	continue;
64
+            }
61 65
             $seen[$merge[$i]] = true;
62 66
             // foreach attribute of the inclusion, copy it over
63
-            if (!isset($this->info[$merge[$i]])) continue;
67
+            if (!isset($this->info[$merge[$i]])) {
68
+            	continue;
69
+            }
64 70
             foreach ($this->info[$merge[$i]] as $key => $value) {
65
-                if (isset($attr[$key])) continue; // also catches more inclusions
71
+                if (isset($attr[$key])) {
72
+                	continue;
73
+                }
74
+                // also catches more inclusions
66 75
                 $attr[$key] = $value;
67 76
             }
68 77
             if (isset($this->info[$merge[$i]][0])) {
@@ -87,9 +96,13 @@  discard block
 block discarded – undo
87 96
 
88 97
         foreach ($attr as $def_i => $def) {
89 98
             // skip inclusions
90
-            if ($def_i === 0) continue;
99
+            if ($def_i === 0) {
100
+            	continue;
101
+            }
91 102
 
92
-            if (isset($processed[$def_i])) continue;
103
+            if (isset($processed[$def_i])) {
104
+            	continue;
105
+            }
93 106
 
94 107
             // determine whether or not attribute is required
95 108
             if ($required = (strpos($def_i, '*') !== false)) {
Please login to merge, or discard this patch.
classes/security/htmlpurifier/library/HTMLPurifier/AttrDef.php 2 patches
Indentation   +98 added lines, -98 removed lines patch added patch discarded remove patch
@@ -13,110 +13,110 @@
 block discarded – undo
13 13
 abstract class HTMLPurifier_AttrDef
14 14
 {
15 15
 
16
-    /**
17
-     * Tells us whether or not an HTML attribute is minimized. Has no
18
-     * meaning in other contexts.
19
-     */
20
-    public $minimized = false;
16
+	/**
17
+	 * Tells us whether or not an HTML attribute is minimized. Has no
18
+	 * meaning in other contexts.
19
+	 */
20
+	public $minimized = false;
21 21
 
22
-    /**
23
-     * Tells us whether or not an HTML attribute is required. Has no
24
-     * meaning in other contexts
25
-     */
26
-    public $required = false;
22
+	/**
23
+	 * Tells us whether or not an HTML attribute is required. Has no
24
+	 * meaning in other contexts
25
+	 */
26
+	public $required = false;
27 27
 
28
-    /**
29
-     * Validates and cleans passed string according to a definition.
30
-     *
31
-     * @param $string String to be validated and cleaned.
32
-     * @param $config Mandatory HTMLPurifier_Config object.
33
-     * @param $context Mandatory HTMLPurifier_AttrContext object.
34
-     */
35
-    abstract public function validate($string, $config, $context);
28
+	/**
29
+	 * Validates and cleans passed string according to a definition.
30
+	 *
31
+	 * @param $string String to be validated and cleaned.
32
+	 * @param $config Mandatory HTMLPurifier_Config object.
33
+	 * @param $context Mandatory HTMLPurifier_AttrContext object.
34
+	 */
35
+	abstract public function validate($string, $config, $context);
36 36
 
37
-    /**
38
-     * Convenience method that parses a string as if it were CDATA.
39
-     *
40
-     * This method process a string in the manner specified at
41
-     * <http://www.w3.org/TR/html4/types.html#h-6.2> by removing
42
-     * leading and trailing whitespace, ignoring line feeds, and replacing
43
-     * carriage returns and tabs with spaces.  While most useful for HTML
44
-     * attributes specified as CDATA, it can also be applied to most CSS
45
-     * values.
46
-     *
47
-     * @note This method is not entirely standards compliant, as trim() removes
48
-     *       more types of whitespace than specified in the spec. In practice,
49
-     *       this is rarely a problem, as those extra characters usually have
50
-     *       already been removed by HTMLPurifier_Encoder.
51
-     *
52
-     * @warning This processing is inconsistent with XML's whitespace handling
53
-     *          as specified by section 3.3.3 and referenced XHTML 1.0 section
54
-     *          4.7.  However, note that we are NOT necessarily
55
-     *          parsing XML, thus, this behavior may still be correct. We
56
-     *          assume that newlines have been normalized.
57
-     */
58
-    public function parseCDATA($string) {
59
-        $string = trim($string);
60
-        $string = str_replace(array("\n", "\t", "\r"), ' ', $string);
61
-        return $string;
62
-    }
37
+	/**
38
+	 * Convenience method that parses a string as if it were CDATA.
39
+	 *
40
+	 * This method process a string in the manner specified at
41
+	 * <http://www.w3.org/TR/html4/types.html#h-6.2> by removing
42
+	 * leading and trailing whitespace, ignoring line feeds, and replacing
43
+	 * carriage returns and tabs with spaces.  While most useful for HTML
44
+	 * attributes specified as CDATA, it can also be applied to most CSS
45
+	 * values.
46
+	 *
47
+	 * @note This method is not entirely standards compliant, as trim() removes
48
+	 *       more types of whitespace than specified in the spec. In practice,
49
+	 *       this is rarely a problem, as those extra characters usually have
50
+	 *       already been removed by HTMLPurifier_Encoder.
51
+	 *
52
+	 * @warning This processing is inconsistent with XML's whitespace handling
53
+	 *          as specified by section 3.3.3 and referenced XHTML 1.0 section
54
+	 *          4.7.  However, note that we are NOT necessarily
55
+	 *          parsing XML, thus, this behavior may still be correct. We
56
+	 *          assume that newlines have been normalized.
57
+	 */
58
+	public function parseCDATA($string) {
59
+		$string = trim($string);
60
+		$string = str_replace(array("\n", "\t", "\r"), ' ', $string);
61
+		return $string;
62
+	}
63 63
 
64
-    /**
65
-     * Factory method for creating this class from a string.
66
-     * @param $string String construction info
67
-     * @return Created AttrDef object corresponding to $string
68
-     */
69
-    public function make($string) {
70
-        // default implementation, return a flyweight of this object.
71
-        // If $string has an effect on the returned object (i.e. you
72
-        // need to overload this method), it is best
73
-        // to clone or instantiate new copies. (Instantiation is safer.)
74
-        return $this;
75
-    }
64
+	/**
65
+	 * Factory method for creating this class from a string.
66
+	 * @param $string String construction info
67
+	 * @return Created AttrDef object corresponding to $string
68
+	 */
69
+	public function make($string) {
70
+		// default implementation, return a flyweight of this object.
71
+		// If $string has an effect on the returned object (i.e. you
72
+		// need to overload this method), it is best
73
+		// to clone or instantiate new copies. (Instantiation is safer.)
74
+		return $this;
75
+	}
76 76
 
77
-    /**
78
-     * Removes spaces from rgb(0, 0, 0) so that shorthand CSS properties work
79
-     * properly. THIS IS A HACK!
80
-     */
81
-    protected function mungeRgb($string) {
82
-        return preg_replace('/rgb\((\d+)\s*,\s*(\d+)\s*,\s*(\d+)\)/', 'rgb(\1,\2,\3)', $string);
83
-    }
77
+	/**
78
+	 * Removes spaces from rgb(0, 0, 0) so that shorthand CSS properties work
79
+	 * properly. THIS IS A HACK!
80
+	 */
81
+	protected function mungeRgb($string) {
82
+		return preg_replace('/rgb\((\d+)\s*,\s*(\d+)\s*,\s*(\d+)\)/', 'rgb(\1,\2,\3)', $string);
83
+	}
84 84
 
85
-    /**
86
-     * Parses a possibly escaped CSS string and returns the "pure" 
87
-     * version of it.
88
-     */
89
-    protected function expandCSSEscape($string) {
90
-        // flexibly parse it
91
-        $ret = '';
92
-        for ($i = 0, $c = strlen($string); $i < $c; $i++) {
93
-            if ($string[$i] === '\\') {
94
-                $i++;
95
-                if ($i >= $c) {
96
-                    $ret .= '\\';
97
-                    break;
98
-                }
99
-                if (ctype_xdigit($string[$i])) {
100
-                    $code = $string[$i];
101
-                    for ($a = 1, $i++; $i < $c && $a < 6; $i++, $a++) {
102
-                        if (!ctype_xdigit($string[$i])) break;
103
-                        $code .= $string[$i];
104
-                    }
105
-                    // We have to be extremely careful when adding
106
-                    // new characters, to make sure we're not breaking
107
-                    // the encoding.
108
-                    $char = HTMLPurifier_Encoder::unichr(hexdec($code));
109
-                    if (HTMLPurifier_Encoder::cleanUTF8($char) === '') continue;
110
-                    $ret .= $char;
111
-                    if ($i < $c && trim($string[$i]) !== '') $i--;
112
-                    continue;
113
-                }
114
-                if ($string[$i] === "\n") continue;
115
-            }
116
-            $ret .= $string[$i];
117
-        }
118
-        return $ret;
119
-    }
85
+	/**
86
+	 * Parses a possibly escaped CSS string and returns the "pure" 
87
+	 * version of it.
88
+	 */
89
+	protected function expandCSSEscape($string) {
90
+		// flexibly parse it
91
+		$ret = '';
92
+		for ($i = 0, $c = strlen($string); $i < $c; $i++) {
93
+			if ($string[$i] === '\\') {
94
+				$i++;
95
+				if ($i >= $c) {
96
+					$ret .= '\\';
97
+					break;
98
+				}
99
+				if (ctype_xdigit($string[$i])) {
100
+					$code = $string[$i];
101
+					for ($a = 1, $i++; $i < $c && $a < 6; $i++, $a++) {
102
+						if (!ctype_xdigit($string[$i])) break;
103
+						$code .= $string[$i];
104
+					}
105
+					// We have to be extremely careful when adding
106
+					// new characters, to make sure we're not breaking
107
+					// the encoding.
108
+					$char = HTMLPurifier_Encoder::unichr(hexdec($code));
109
+					if (HTMLPurifier_Encoder::cleanUTF8($char) === '') continue;
110
+					$ret .= $char;
111
+					if ($i < $c && trim($string[$i]) !== '') $i--;
112
+					continue;
113
+				}
114
+				if ($string[$i] === "\n") continue;
115
+			}
116
+			$ret .= $string[$i];
117
+		}
118
+		return $ret;
119
+	}
120 120
 
121 121
 }
122 122
 
Please login to merge, or discard this patch.
Braces   +12 added lines, -4 removed lines patch added patch discarded remove patch
@@ -99,19 +99,27 @@
 block discarded – undo
99 99
                 if (ctype_xdigit($string[$i])) {
100 100
                     $code = $string[$i];
101 101
                     for ($a = 1, $i++; $i < $c && $a < 6; $i++, $a++) {
102
-                        if (!ctype_xdigit($string[$i])) break;
102
+                        if (!ctype_xdigit($string[$i])) {
103
+                        	break;
104
+                        }
103 105
                         $code .= $string[$i];
104 106
                     }
105 107
                     // We have to be extremely careful when adding
106 108
                     // new characters, to make sure we're not breaking
107 109
                     // the encoding.
108 110
                     $char = HTMLPurifier_Encoder::unichr(hexdec($code));
109
-                    if (HTMLPurifier_Encoder::cleanUTF8($char) === '') continue;
111
+                    if (HTMLPurifier_Encoder::cleanUTF8($char) === '') {
112
+                    	continue;
113
+                    }
110 114
                     $ret .= $char;
111
-                    if ($i < $c && trim($string[$i]) !== '') $i--;
115
+                    if ($i < $c && trim($string[$i]) !== '') {
116
+                    	$i--;
117
+                    }
112 118
                     continue;
113 119
                 }
114
-                if ($string[$i] === "\n") continue;
120
+                if ($string[$i] === "\n") {
121
+                	continue;
122
+                }
115 123
             }
116 124
             $ret .= $string[$i];
117 125
         }
Please login to merge, or discard this patch.
classes/security/htmlpurifier/library/HTMLPurifier/AttrDef/CSS.php 3 patches
Indentation   +56 added lines, -56 removed lines patch added patch discarded remove patch
@@ -14,73 +14,73 @@
 block discarded – undo
14 14
 class HTMLPurifier_AttrDef_CSS extends HTMLPurifier_AttrDef
15 15
 {
16 16
 
17
-    public function validate($css, $config, $context) {
17
+	public function validate($css, $config, $context) {
18 18
 
19
-        $css = $this->parseCDATA($css);
19
+		$css = $this->parseCDATA($css);
20 20
 
21
-        $definition = $config->getCSSDefinition();
21
+		$definition = $config->getCSSDefinition();
22 22
 
23
-        // we're going to break the spec and explode by semicolons.
24
-        // This is because semicolon rarely appears in escaped form
25
-        // Doing this is generally flaky but fast
26
-        // IT MIGHT APPEAR IN URIs, see HTMLPurifier_AttrDef_CSSURI
27
-        // for details
23
+		// we're going to break the spec and explode by semicolons.
24
+		// This is because semicolon rarely appears in escaped form
25
+		// Doing this is generally flaky but fast
26
+		// IT MIGHT APPEAR IN URIs, see HTMLPurifier_AttrDef_CSSURI
27
+		// for details
28 28
 
29
-        $declarations = explode(';', $css);
30
-        $propvalues = array();
29
+		$declarations = explode(';', $css);
30
+		$propvalues = array();
31 31
 
32
-        /**
33
-         * Name of the current CSS property being validated.
34
-         */
35
-        $property = false;
36
-        $context->register('CurrentCSSProperty', $property);
32
+		/**
33
+		 * Name of the current CSS property being validated.
34
+		 */
35
+		$property = false;
36
+		$context->register('CurrentCSSProperty', $property);
37 37
 
38
-        foreach ($declarations as $declaration) {
39
-            if (!$declaration) continue;
40
-            if (!strpos($declaration, ':')) continue;
41
-            list($property, $value) = explode(':', $declaration, 2);
42
-            $property = trim($property);
43
-            $value    = trim($value);
44
-            $ok = false;
45
-            do {
46
-                if (isset($definition->info[$property])) {
47
-                    $ok = true;
48
-                    break;
49
-                }
50
-                if (ctype_lower($property)) break;
51
-                $property = strtolower($property);
52
-                if (isset($definition->info[$property])) {
53
-                    $ok = true;
54
-                    break;
55
-                }
56
-            } while(0);
57
-            if (!$ok) continue;
58
-            // inefficient call, since the validator will do this again
59
-            if (strtolower(trim($value)) !== 'inherit') {
60
-                // inherit works for everything (but only on the base property)
61
-                $result = $definition->info[$property]->validate(
62
-                    $value, $config, $context );
63
-            } else {
64
-                $result = 'inherit';
65
-            }
66
-            if ($result === false) continue;
67
-            $propvalues[$property] = $result;
68
-        }
38
+		foreach ($declarations as $declaration) {
39
+			if (!$declaration) continue;
40
+			if (!strpos($declaration, ':')) continue;
41
+			list($property, $value) = explode(':', $declaration, 2);
42
+			$property = trim($property);
43
+			$value    = trim($value);
44
+			$ok = false;
45
+			do {
46
+				if (isset($definition->info[$property])) {
47
+					$ok = true;
48
+					break;
49
+				}
50
+				if (ctype_lower($property)) break;
51
+				$property = strtolower($property);
52
+				if (isset($definition->info[$property])) {
53
+					$ok = true;
54
+					break;
55
+				}
56
+			} while(0);
57
+			if (!$ok) continue;
58
+			// inefficient call, since the validator will do this again
59
+			if (strtolower(trim($value)) !== 'inherit') {
60
+				// inherit works for everything (but only on the base property)
61
+				$result = $definition->info[$property]->validate(
62
+					$value, $config, $context );
63
+			} else {
64
+				$result = 'inherit';
65
+			}
66
+			if ($result === false) continue;
67
+			$propvalues[$property] = $result;
68
+		}
69 69
 
70
-        $context->destroy('CurrentCSSProperty');
70
+		$context->destroy('CurrentCSSProperty');
71 71
 
72
-        // procedure does not write the new CSS simultaneously, so it's
73
-        // slightly inefficient, but it's the only way of getting rid of
74
-        // duplicates. Perhaps config to optimize it, but not now.
72
+		// procedure does not write the new CSS simultaneously, so it's
73
+		// slightly inefficient, but it's the only way of getting rid of
74
+		// duplicates. Perhaps config to optimize it, but not now.
75 75
 
76
-        $new_declarations = '';
77
-        foreach ($propvalues as $prop => $value) {
78
-            $new_declarations .= "$prop:$value;";
79
-        }
76
+		$new_declarations = '';
77
+		foreach ($propvalues as $prop => $value) {
78
+			$new_declarations .= "$prop:$value;";
79
+		}
80 80
 
81
-        return $new_declarations ? $new_declarations : false;
81
+		return $new_declarations ? $new_declarations : false;
82 82
 
83
-    }
83
+	}
84 84
 
85 85
 }
86 86
 
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -53,7 +53,7 @@
 block discarded – undo
53 53
                     $ok = true;
54 54
                     break;
55 55
                 }
56
-            } while(0);
56
+            } while (0);
57 57
             if (!$ok) continue;
58 58
             // inefficient call, since the validator will do this again
59 59
             if (strtolower(trim($value)) !== 'inherit') {
Please login to merge, or discard this patch.
Braces   +15 added lines, -5 removed lines patch added patch discarded remove patch
@@ -36,8 +36,12 @@  discard block
 block discarded – undo
36 36
         $context->register('CurrentCSSProperty', $property);
37 37
 
38 38
         foreach ($declarations as $declaration) {
39
-            if (!$declaration) continue;
40
-            if (!strpos($declaration, ':')) continue;
39
+            if (!$declaration) {
40
+            	continue;
41
+            }
42
+            if (!strpos($declaration, ':')) {
43
+            	continue;
44
+            }
41 45
             list($property, $value) = explode(':', $declaration, 2);
42 46
             $property = trim($property);
43 47
             $value    = trim($value);
@@ -47,14 +51,18 @@  discard block
 block discarded – undo
47 51
                     $ok = true;
48 52
                     break;
49 53
                 }
50
-                if (ctype_lower($property)) break;
54
+                if (ctype_lower($property)) {
55
+                	break;
56
+                }
51 57
                 $property = strtolower($property);
52 58
                 if (isset($definition->info[$property])) {
53 59
                     $ok = true;
54 60
                     break;
55 61
                 }
56 62
             } while(0);
57
-            if (!$ok) continue;
63
+            if (!$ok) {
64
+            	continue;
65
+            }
58 66
             // inefficient call, since the validator will do this again
59 67
             if (strtolower(trim($value)) !== 'inherit') {
60 68
                 // inherit works for everything (but only on the base property)
@@ -63,7 +71,9 @@  discard block
 block discarded – undo
63 71
             } else {
64 72
                 $result = 'inherit';
65 73
             }
66
-            if ($result === false) continue;
74
+            if ($result === false) {
75
+            	continue;
76
+            }
67 77
             $propvalues[$property] = $result;
68 78
         }
69 79
 
Please login to merge, or discard this patch.
security/htmlpurifier/library/HTMLPurifier/AttrDef/CSS/AlphaValue.php 2 patches
Indentation   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -3,18 +3,18 @@
 block discarded – undo
3 3
 class HTMLPurifier_AttrDef_CSS_AlphaValue extends HTMLPurifier_AttrDef_CSS_Number
4 4
 {
5 5
 
6
-    public function __construct() {
7
-        parent::__construct(false); // opacity is non-negative, but we will clamp it
8
-    }
6
+	public function __construct() {
7
+		parent::__construct(false); // opacity is non-negative, but we will clamp it
8
+	}
9 9
 
10
-    public function validate($number, $config, $context) {
11
-        $result = parent::validate($number, $config, $context);
12
-        if ($result === false) return $result;
13
-        $float = (float) $result;
14
-        if ($float < 0.0) $result = '0';
15
-        if ($float > 1.0) $result = '1';
16
-        return $result;
17
-    }
10
+	public function validate($number, $config, $context) {
11
+		$result = parent::validate($number, $config, $context);
12
+		if ($result === false) return $result;
13
+		$float = (float) $result;
14
+		if ($float < 0.0) $result = '0';
15
+		if ($float > 1.0) $result = '1';
16
+		return $result;
17
+	}
18 18
 
19 19
 }
20 20
 
Please login to merge, or discard this patch.
Braces   +9 added lines, -3 removed lines patch added patch discarded remove patch
@@ -9,10 +9,16 @@
 block discarded – undo
9 9
 
10 10
     public function validate($number, $config, $context) {
11 11
         $result = parent::validate($number, $config, $context);
12
-        if ($result === false) return $result;
12
+        if ($result === false) {
13
+        	return $result;
14
+        }
13 15
         $float = (float) $result;
14
-        if ($float < 0.0) $result = '0';
15
-        if ($float > 1.0) $result = '1';
16
+        if ($float < 0.0) {
17
+        	$result = '0';
18
+        }
19
+        if ($float > 1.0) {
20
+        	$result = '1';
21
+        }
16 22
         return $result;
17 23
     }
18 24
 
Please login to merge, or discard this patch.
security/htmlpurifier/library/HTMLPurifier/AttrDef/CSS/Background.php 3 patches
Indentation   +74 added lines, -74 removed lines patch added patch discarded remove patch
@@ -7,80 +7,80 @@
 block discarded – undo
7 7
 class HTMLPurifier_AttrDef_CSS_Background extends HTMLPurifier_AttrDef
8 8
 {
9 9
 
10
-    /**
11
-     * Local copy of component validators.
12
-     * @note See HTMLPurifier_AttrDef_Font::$info for a similar impl.
13
-     */
14
-    protected $info;
15
-
16
-    public function __construct($config) {
17
-        $def = $config->getCSSDefinition();
18
-        $this->info['background-color'] = $def->info['background-color'];
19
-        $this->info['background-image'] = $def->info['background-image'];
20
-        $this->info['background-repeat'] = $def->info['background-repeat'];
21
-        $this->info['background-attachment'] = $def->info['background-attachment'];
22
-        $this->info['background-position'] = $def->info['background-position'];
23
-    }
24
-
25
-    public function validate($string, $config, $context) {
26
-
27
-        // regular pre-processing
28
-        $string = $this->parseCDATA($string);
29
-        if ($string === '') return false;
30
-
31
-        // munge rgb() decl if necessary
32
-        $string = $this->mungeRgb($string);
33
-
34
-        // assumes URI doesn't have spaces in it
35
-        $bits = explode(' ', strtolower($string)); // bits to process
36
-
37
-        $caught = array();
38
-        $caught['color']    = false;
39
-        $caught['image']    = false;
40
-        $caught['repeat']   = false;
41
-        $caught['attachment'] = false;
42
-        $caught['position'] = false;
43
-
44
-        $i = 0; // number of catches
45
-        $none = false;
46
-
47
-        foreach ($bits as $bit) {
48
-            if ($bit === '') continue;
49
-            foreach ($caught as $key => $status) {
50
-                if ($key != 'position') {
51
-                    if ($status !== false) continue;
52
-                    $r = $this->info['background-' . $key]->validate($bit, $config, $context);
53
-                } else {
54
-                    $r = $bit;
55
-                }
56
-                if ($r === false) continue;
57
-                if ($key == 'position') {
58
-                    if ($caught[$key] === false) $caught[$key] = '';
59
-                    $caught[$key] .= $r . ' ';
60
-                } else {
61
-                    $caught[$key] = $r;
62
-                }
63
-                $i++;
64
-                break;
65
-            }
66
-        }
67
-
68
-        if (!$i) return false;
69
-        if ($caught['position'] !== false) {
70
-            $caught['position'] = $this->info['background-position']->
71
-                validate($caught['position'], $config, $context);
72
-        }
73
-
74
-        $ret = array();
75
-        foreach ($caught as $value) {
76
-            if ($value === false) continue;
77
-            $ret[] = $value;
78
-        }
79
-
80
-        if (empty($ret)) return false;
81
-        return implode(' ', $ret);
82
-
83
-    }
10
+	/**
11
+	 * Local copy of component validators.
12
+	 * @note See HTMLPurifier_AttrDef_Font::$info for a similar impl.
13
+	 */
14
+	protected $info;
15
+
16
+	public function __construct($config) {
17
+		$def = $config->getCSSDefinition();
18
+		$this->info['background-color'] = $def->info['background-color'];
19
+		$this->info['background-image'] = $def->info['background-image'];
20
+		$this->info['background-repeat'] = $def->info['background-repeat'];
21
+		$this->info['background-attachment'] = $def->info['background-attachment'];
22
+		$this->info['background-position'] = $def->info['background-position'];
23
+	}
24
+
25
+	public function validate($string, $config, $context) {
26
+
27
+		// regular pre-processing
28
+		$string = $this->parseCDATA($string);
29
+		if ($string === '') return false;
30
+
31
+		// munge rgb() decl if necessary
32
+		$string = $this->mungeRgb($string);
33
+
34
+		// assumes URI doesn't have spaces in it
35
+		$bits = explode(' ', strtolower($string)); // bits to process
36
+
37
+		$caught = array();
38
+		$caught['color']    = false;
39
+		$caught['image']    = false;
40
+		$caught['repeat']   = false;
41
+		$caught['attachment'] = false;
42
+		$caught['position'] = false;
43
+
44
+		$i = 0; // number of catches
45
+		$none = false;
46
+
47
+		foreach ($bits as $bit) {
48
+			if ($bit === '') continue;
49
+			foreach ($caught as $key => $status) {
50
+				if ($key != 'position') {
51
+					if ($status !== false) continue;
52
+					$r = $this->info['background-' . $key]->validate($bit, $config, $context);
53
+				} else {
54
+					$r = $bit;
55
+				}
56
+				if ($r === false) continue;
57
+				if ($key == 'position') {
58
+					if ($caught[$key] === false) $caught[$key] = '';
59
+					$caught[$key] .= $r . ' ';
60
+				} else {
61
+					$caught[$key] = $r;
62
+				}
63
+				$i++;
64
+				break;
65
+			}
66
+		}
67
+
68
+		if (!$i) return false;
69
+		if ($caught['position'] !== false) {
70
+			$caught['position'] = $this->info['background-position']->
71
+				validate($caught['position'], $config, $context);
72
+		}
73
+
74
+		$ret = array();
75
+		foreach ($caught as $value) {
76
+			if ($value === false) continue;
77
+			$ret[] = $value;
78
+		}
79
+
80
+		if (empty($ret)) return false;
81
+		return implode(' ', $ret);
82
+
83
+	}
84 84
 
85 85
 }
86 86
 
Please login to merge, or discard this patch.
Braces   +24 added lines, -8 removed lines patch added patch discarded remove patch
@@ -26,7 +26,9 @@  discard block
 block discarded – undo
26 26
 
27 27
         // regular pre-processing
28 28
         $string = $this->parseCDATA($string);
29
-        if ($string === '') return false;
29
+        if ($string === '') {
30
+        	return false;
31
+        }
30 32
 
31 33
         // munge rgb() decl if necessary
32 34
         $string = $this->mungeRgb($string);
@@ -45,17 +47,25 @@  discard block
 block discarded – undo
45 47
         $none = false;
46 48
 
47 49
         foreach ($bits as $bit) {
48
-            if ($bit === '') continue;
50
+            if ($bit === '') {
51
+            	continue;
52
+            }
49 53
             foreach ($caught as $key => $status) {
50 54
                 if ($key != 'position') {
51
-                    if ($status !== false) continue;
55
+                    if ($status !== false) {
56
+                    	continue;
57
+                    }
52 58
                     $r = $this->info['background-' . $key]->validate($bit, $config, $context);
53 59
                 } else {
54 60
                     $r = $bit;
55 61
                 }
56
-                if ($r === false) continue;
62
+                if ($r === false) {
63
+                	continue;
64
+                }
57 65
                 if ($key == 'position') {
58
-                    if ($caught[$key] === false) $caught[$key] = '';
66
+                    if ($caught[$key] === false) {
67
+                    	$caught[$key] = '';
68
+                    }
59 69
                     $caught[$key] .= $r . ' ';
60 70
                 } else {
61 71
                     $caught[$key] = $r;
@@ -65,7 +75,9 @@  discard block
 block discarded – undo
65 75
             }
66 76
         }
67 77
 
68
-        if (!$i) return false;
78
+        if (!$i) {
79
+        	return false;
80
+        }
69 81
         if ($caught['position'] !== false) {
70 82
             $caught['position'] = $this->info['background-position']->
71 83
                 validate($caught['position'], $config, $context);
@@ -73,11 +85,15 @@  discard block
 block discarded – undo
73 85
 
74 86
         $ret = array();
75 87
         foreach ($caught as $value) {
76
-            if ($value === false) continue;
88
+            if ($value === false) {
89
+            	continue;
90
+            }
77 91
             $ret[] = $value;
78 92
         }
79 93
 
80
-        if (empty($ret)) return false;
94
+        if (empty($ret)) {
95
+        	return false;
96
+        }
81 97
         return implode(' ', $ret);
82 98
 
83 99
     }
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -49,14 +49,14 @@
 block discarded – undo
49 49
             foreach ($caught as $key => $status) {
50 50
                 if ($key != 'position') {
51 51
                     if ($status !== false) continue;
52
-                    $r = $this->info['background-' . $key]->validate($bit, $config, $context);
52
+                    $r = $this->info['background-'.$key]->validate($bit, $config, $context);
53 53
                 } else {
54 54
                     $r = $bit;
55 55
                 }
56 56
                 if ($r === false) continue;
57 57
                 if ($key == 'position') {
58 58
                     if ($caught[$key] === false) $caught[$key] = '';
59
-                    $caught[$key] .= $r . ' ';
59
+                    $caught[$key] .= $r.' ';
60 60
                 } else {
61 61
                     $caught[$key] = $r;
62 62
                 }
Please login to merge, or discard this patch.
htmlpurifier/library/HTMLPurifier/AttrDef/CSS/BackgroundPosition.php 3 patches
Indentation   +83 added lines, -83 removed lines patch added patch discarded remove patch
@@ -44,89 +44,89 @@
 block discarded – undo
44 44
 class HTMLPurifier_AttrDef_CSS_BackgroundPosition extends HTMLPurifier_AttrDef
45 45
 {
46 46
 
47
-    protected $length;
48
-    protected $percentage;
49
-
50
-    public function __construct() {
51
-        $this->length     = new HTMLPurifier_AttrDef_CSS_Length();
52
-        $this->percentage = new HTMLPurifier_AttrDef_CSS_Percentage();
53
-    }
54
-
55
-    public function validate($string, $config, $context) {
56
-        $string = $this->parseCDATA($string);
57
-        $bits = explode(' ', $string);
58
-
59
-        $keywords = array();
60
-        $keywords['h'] = false; // left, right
61
-        $keywords['v'] = false; // top, bottom
62
-        $keywords['ch'] = false; // center (first word)
63
-        $keywords['cv'] = false; // center (second word)
64
-        $measures = array();
65
-
66
-        $i = 0;
67
-
68
-        $lookup = array(
69
-            'top' => 'v',
70
-            'bottom' => 'v',
71
-            'left' => 'h',
72
-            'right' => 'h',
73
-            'center' => 'c'
74
-        );
75
-
76
-        foreach ($bits as $bit) {
77
-            if ($bit === '') continue;
78
-
79
-            // test for keyword
80
-            $lbit = ctype_lower($bit) ? $bit : strtolower($bit);
81
-            if (isset($lookup[$lbit])) {
82
-                $status = $lookup[$lbit];
83
-                if ($status == 'c') {
84
-                    if ($i == 0) {
85
-                        $status = 'ch';
86
-                    } else {
87
-                        $status = 'cv';
88
-                    }
89
-                }
90
-                $keywords[$status] = $lbit;
91
-                $i++;
92
-            }
93
-
94
-            // test for length
95
-            $r = $this->length->validate($bit, $config, $context);
96
-            if ($r !== false) {
97
-                $measures[] = $r;
98
-                $i++;
99
-            }
100
-
101
-            // test for percentage
102
-            $r = $this->percentage->validate($bit, $config, $context);
103
-            if ($r !== false) {
104
-                $measures[] = $r;
105
-                $i++;
106
-            }
107
-
108
-        }
109
-
110
-        if (!$i) return false; // no valid values were caught
111
-
112
-        $ret = array();
113
-
114
-        // first keyword
115
-        if     ($keywords['h'])     $ret[] = $keywords['h'];
116
-        elseif ($keywords['ch']) {
117
-            $ret[] = $keywords['ch'];
118
-            $keywords['cv'] = false; // prevent re-use: center = center center
119
-        }
120
-        elseif (count($measures))   $ret[] = array_shift($measures);
121
-
122
-        if     ($keywords['v'])     $ret[] = $keywords['v'];
123
-        elseif ($keywords['cv'])    $ret[] = $keywords['cv'];
124
-        elseif (count($measures))   $ret[] = array_shift($measures);
125
-
126
-        if (empty($ret)) return false;
127
-        return implode(' ', $ret);
128
-
129
-    }
47
+	protected $length;
48
+	protected $percentage;
49
+
50
+	public function __construct() {
51
+		$this->length     = new HTMLPurifier_AttrDef_CSS_Length();
52
+		$this->percentage = new HTMLPurifier_AttrDef_CSS_Percentage();
53
+	}
54
+
55
+	public function validate($string, $config, $context) {
56
+		$string = $this->parseCDATA($string);
57
+		$bits = explode(' ', $string);
58
+
59
+		$keywords = array();
60
+		$keywords['h'] = false; // left, right
61
+		$keywords['v'] = false; // top, bottom
62
+		$keywords['ch'] = false; // center (first word)
63
+		$keywords['cv'] = false; // center (second word)
64
+		$measures = array();
65
+
66
+		$i = 0;
67
+
68
+		$lookup = array(
69
+			'top' => 'v',
70
+			'bottom' => 'v',
71
+			'left' => 'h',
72
+			'right' => 'h',
73
+			'center' => 'c'
74
+		);
75
+
76
+		foreach ($bits as $bit) {
77
+			if ($bit === '') continue;
78
+
79
+			// test for keyword
80
+			$lbit = ctype_lower($bit) ? $bit : strtolower($bit);
81
+			if (isset($lookup[$lbit])) {
82
+				$status = $lookup[$lbit];
83
+				if ($status == 'c') {
84
+					if ($i == 0) {
85
+						$status = 'ch';
86
+					} else {
87
+						$status = 'cv';
88
+					}
89
+				}
90
+				$keywords[$status] = $lbit;
91
+				$i++;
92
+			}
93
+
94
+			// test for length
95
+			$r = $this->length->validate($bit, $config, $context);
96
+			if ($r !== false) {
97
+				$measures[] = $r;
98
+				$i++;
99
+			}
100
+
101
+			// test for percentage
102
+			$r = $this->percentage->validate($bit, $config, $context);
103
+			if ($r !== false) {
104
+				$measures[] = $r;
105
+				$i++;
106
+			}
107
+
108
+		}
109
+
110
+		if (!$i) return false; // no valid values were caught
111
+
112
+		$ret = array();
113
+
114
+		// first keyword
115
+		if     ($keywords['h'])     $ret[] = $keywords['h'];
116
+		elseif ($keywords['ch']) {
117
+			$ret[] = $keywords['ch'];
118
+			$keywords['cv'] = false; // prevent re-use: center = center center
119
+		}
120
+		elseif (count($measures))   $ret[] = array_shift($measures);
121
+
122
+		if     ($keywords['v'])     $ret[] = $keywords['v'];
123
+		elseif ($keywords['cv'])    $ret[] = $keywords['cv'];
124
+		elseif (count($measures))   $ret[] = array_shift($measures);
125
+
126
+		if (empty($ret)) return false;
127
+		return implode(' ', $ret);
128
+
129
+	}
130 130
 
131 131
 }
132 132
 
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -112,14 +112,14 @@
 block discarded – undo
112 112
         $ret = array();
113 113
 
114 114
         // first keyword
115
-        if     ($keywords['h'])     $ret[] = $keywords['h'];
115
+        if ($keywords['h'])     $ret[] = $keywords['h'];
116 116
         elseif ($keywords['ch']) {
117 117
             $ret[] = $keywords['ch'];
118 118
             $keywords['cv'] = false; // prevent re-use: center = center center
119 119
         }
120 120
         elseif (count($measures))   $ret[] = array_shift($measures);
121 121
 
122
-        if     ($keywords['v'])     $ret[] = $keywords['v'];
122
+        if ($keywords['v'])     $ret[] = $keywords['v'];
123 123
         elseif ($keywords['cv'])    $ret[] = $keywords['cv'];
124 124
         elseif (count($measures))   $ret[] = array_shift($measures);
125 125
 
Please login to merge, or discard this patch.
Braces   +22 added lines, -9 removed lines patch added patch discarded remove patch
@@ -74,7 +74,9 @@  discard block
 block discarded – undo
74 74
         );
75 75
 
76 76
         foreach ($bits as $bit) {
77
-            if ($bit === '') continue;
77
+            if ($bit === '') {
78
+            	continue;
79
+            }
78 80
 
79 81
             // test for keyword
80 82
             $lbit = ctype_lower($bit) ? $bit : strtolower($bit);
@@ -107,23 +109,34 @@  discard block
 block discarded – undo
107 109
 
108 110
         }
109 111
 
110
-        if (!$i) return false; // no valid values were caught
112
+        if (!$i) {
113
+        	return false;
114
+        }
115
+        // no valid values were caught
111 116
 
112 117
         $ret = array();
113 118
 
114 119
         // first keyword
115
-        if     ($keywords['h'])     $ret[] = $keywords['h'];
116
-        elseif ($keywords['ch']) {
120
+        if     ($keywords['h']) {
121
+        	$ret[] = $keywords['h'];
122
+        } elseif ($keywords['ch']) {
117 123
             $ret[] = $keywords['ch'];
118 124
             $keywords['cv'] = false; // prevent re-use: center = center center
125
+        } elseif (count($measures)) {
126
+        	$ret[] = array_shift($measures);
119 127
         }
120
-        elseif (count($measures))   $ret[] = array_shift($measures);
121 128
 
122
-        if     ($keywords['v'])     $ret[] = $keywords['v'];
123
-        elseif ($keywords['cv'])    $ret[] = $keywords['cv'];
124
-        elseif (count($measures))   $ret[] = array_shift($measures);
129
+        if     ($keywords['v']) {
130
+        	$ret[] = $keywords['v'];
131
+        } elseif ($keywords['cv']) {
132
+        	$ret[] = $keywords['cv'];
133
+        } elseif (count($measures)) {
134
+        	$ret[] = array_shift($measures);
135
+        }
125 136
 
126
-        if (empty($ret)) return false;
137
+        if (empty($ret)) {
138
+        	return false;
139
+        }
127 140
         return implode(' ', $ret);
128 141
 
129 142
     }
Please login to merge, or discard this patch.