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/AttrDef/HTML/ID.php 3 patches
Indentation   +62 added lines, -62 removed lines patch added patch discarded remove patch
@@ -12,68 +12,68 @@
 block discarded – undo
12 12
 class HTMLPurifier_AttrDef_HTML_ID extends HTMLPurifier_AttrDef
13 13
 {
14 14
 
15
-    // selector is NOT a valid thing to use for IDREFs, because IDREFs
16
-    // *must* target IDs that exist, whereas selector #ids do not.
17
-
18
-    /**
19
-     * Determines whether or not we're validating an ID in a CSS
20
-     * selector context.
21
-     */
22
-    protected $selector;
23
-
24
-    public function __construct($selector = false) {
25
-        $this->selector = $selector;
26
-    }
27
-
28
-    public function validate($id, $config, $context) {
29
-
30
-        if (!$this->selector && !$config->get('Attr.EnableID')) return false;
31
-
32
-        $id = trim($id); // trim it first
33
-
34
-        if ($id === '') return false;
35
-
36
-        $prefix = $config->get('Attr.IDPrefix');
37
-        if ($prefix !== '') {
38
-            $prefix .= $config->get('Attr.IDPrefixLocal');
39
-            // prevent re-appending the prefix
40
-            if (strpos($id, $prefix) !== 0) $id = $prefix . $id;
41
-        } elseif ($config->get('Attr.IDPrefixLocal') !== '') {
42
-            trigger_error('%Attr.IDPrefixLocal cannot be used unless '.
43
-                '%Attr.IDPrefix is set', E_USER_WARNING);
44
-        }
45
-
46
-        if (!$this->selector) {
47
-            $id_accumulator =& $context->get('IDAccumulator');
48
-            if (isset($id_accumulator->ids[$id])) return false;
49
-        }
50
-
51
-        // we purposely avoid using regex, hopefully this is faster
52
-
53
-        if (ctype_alpha($id)) {
54
-            $result = true;
55
-        } else {
56
-            if (!ctype_alpha(@$id[0])) return false;
57
-            $trim = trim( // primitive style of regexps, I suppose
58
-                $id,
59
-                'A..Za..z0..9:-._'
60
-              );
61
-            $result = ($trim === '');
62
-        }
63
-
64
-        $regexp = $config->get('Attr.IDBlacklistRegexp');
65
-        if ($regexp && preg_match($regexp, $id)) {
66
-            return false;
67
-        }
68
-
69
-        if (!$this->selector && $result) $id_accumulator->add($id);
70
-
71
-        // if no change was made to the ID, return the result
72
-        // else, return the new id if stripping whitespace made it
73
-        //     valid, or return false.
74
-        return $result ? $id : false;
75
-
76
-    }
15
+	// selector is NOT a valid thing to use for IDREFs, because IDREFs
16
+	// *must* target IDs that exist, whereas selector #ids do not.
17
+
18
+	/**
19
+	 * Determines whether or not we're validating an ID in a CSS
20
+	 * selector context.
21
+	 */
22
+	protected $selector;
23
+
24
+	public function __construct($selector = false) {
25
+		$this->selector = $selector;
26
+	}
27
+
28
+	public function validate($id, $config, $context) {
29
+
30
+		if (!$this->selector && !$config->get('Attr.EnableID')) return false;
31
+
32
+		$id = trim($id); // trim it first
33
+
34
+		if ($id === '') return false;
35
+
36
+		$prefix = $config->get('Attr.IDPrefix');
37
+		if ($prefix !== '') {
38
+			$prefix .= $config->get('Attr.IDPrefixLocal');
39
+			// prevent re-appending the prefix
40
+			if (strpos($id, $prefix) !== 0) $id = $prefix . $id;
41
+		} elseif ($config->get('Attr.IDPrefixLocal') !== '') {
42
+			trigger_error('%Attr.IDPrefixLocal cannot be used unless '.
43
+				'%Attr.IDPrefix is set', E_USER_WARNING);
44
+		}
45
+
46
+		if (!$this->selector) {
47
+			$id_accumulator =& $context->get('IDAccumulator');
48
+			if (isset($id_accumulator->ids[$id])) return false;
49
+		}
50
+
51
+		// we purposely avoid using regex, hopefully this is faster
52
+
53
+		if (ctype_alpha($id)) {
54
+			$result = true;
55
+		} else {
56
+			if (!ctype_alpha(@$id[0])) return false;
57
+			$trim = trim( // primitive style of regexps, I suppose
58
+				$id,
59
+				'A..Za..z0..9:-._'
60
+			  );
61
+			$result = ($trim === '');
62
+		}
63
+
64
+		$regexp = $config->get('Attr.IDBlacklistRegexp');
65
+		if ($regexp && preg_match($regexp, $id)) {
66
+			return false;
67
+		}
68
+
69
+		if (!$this->selector && $result) $id_accumulator->add($id);
70
+
71
+		// if no change was made to the ID, return the result
72
+		// else, return the new id if stripping whitespace made it
73
+		//     valid, or return false.
74
+		return $result ? $id : false;
75
+
76
+	}
77 77
 
78 78
 }
79 79
 
Please login to merge, or discard this patch.
Braces   +18 added lines, -6 removed lines patch added patch discarded remove patch
@@ -27,17 +27,23 @@  discard block
 block discarded – undo
27 27
 
28 28
     public function validate($id, $config, $context) {
29 29
 
30
-        if (!$this->selector && !$config->get('Attr.EnableID')) return false;
30
+        if (!$this->selector && !$config->get('Attr.EnableID')) {
31
+        	return false;
32
+        }
31 33
 
32 34
         $id = trim($id); // trim it first
33 35
 
34
-        if ($id === '') return false;
36
+        if ($id === '') {
37
+        	return false;
38
+        }
35 39
 
36 40
         $prefix = $config->get('Attr.IDPrefix');
37 41
         if ($prefix !== '') {
38 42
             $prefix .= $config->get('Attr.IDPrefixLocal');
39 43
             // prevent re-appending the prefix
40
-            if (strpos($id, $prefix) !== 0) $id = $prefix . $id;
44
+            if (strpos($id, $prefix) !== 0) {
45
+            	$id = $prefix . $id;
46
+            }
41 47
         } elseif ($config->get('Attr.IDPrefixLocal') !== '') {
42 48
             trigger_error('%Attr.IDPrefixLocal cannot be used unless '.
43 49
                 '%Attr.IDPrefix is set', E_USER_WARNING);
@@ -45,7 +51,9 @@  discard block
 block discarded – undo
45 51
 
46 52
         if (!$this->selector) {
47 53
             $id_accumulator =& $context->get('IDAccumulator');
48
-            if (isset($id_accumulator->ids[$id])) return false;
54
+            if (isset($id_accumulator->ids[$id])) {
55
+            	return false;
56
+            }
49 57
         }
50 58
 
51 59
         // we purposely avoid using regex, hopefully this is faster
@@ -53,7 +61,9 @@  discard block
 block discarded – undo
53 61
         if (ctype_alpha($id)) {
54 62
             $result = true;
55 63
         } else {
56
-            if (!ctype_alpha(@$id[0])) return false;
64
+            if (!ctype_alpha(@$id[0])) {
65
+            	return false;
66
+            }
57 67
             $trim = trim( // primitive style of regexps, I suppose
58 68
                 $id,
59 69
                 'A..Za..z0..9:-._'
@@ -66,7 +76,9 @@  discard block
 block discarded – undo
66 76
             return false;
67 77
         }
68 78
 
69
-        if (!$this->selector && $result) $id_accumulator->add($id);
79
+        if (!$this->selector && $result) {
80
+        	$id_accumulator->add($id);
81
+        }
70 82
 
71 83
         // if no change was made to the ID, return the result
72 84
         // else, return the new id if stripping whitespace made it
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -37,14 +37,14 @@
 block discarded – undo
37 37
         if ($prefix !== '') {
38 38
             $prefix .= $config->get('Attr.IDPrefixLocal');
39 39
             // prevent re-appending the prefix
40
-            if (strpos($id, $prefix) !== 0) $id = $prefix . $id;
40
+            if (strpos($id, $prefix) !== 0) $id = $prefix.$id;
41 41
         } elseif ($config->get('Attr.IDPrefixLocal') !== '') {
42 42
             trigger_error('%Attr.IDPrefixLocal cannot be used unless '.
43 43
                 '%Attr.IDPrefix is set', E_USER_WARNING);
44 44
         }
45 45
 
46 46
         if (!$this->selector) {
47
-            $id_accumulator =& $context->get('IDAccumulator');
47
+            $id_accumulator = & $context->get('IDAccumulator');
48 48
             if (isset($id_accumulator->ids[$id])) return false;
49 49
         }
50 50
 
Please login to merge, or discard this patch.
classes/security/htmlpurifier/library/HTMLPurifier/AttrDef/HTML/Length.php 3 patches
Indentation   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -10,31 +10,31 @@
 block discarded – undo
10 10
 class HTMLPurifier_AttrDef_HTML_Length extends HTMLPurifier_AttrDef_HTML_Pixels
11 11
 {
12 12
 
13
-    public function validate($string, $config, $context) {
13
+	public function validate($string, $config, $context) {
14 14
 
15
-        $string = trim($string);
16
-        if ($string === '') return false;
15
+		$string = trim($string);
16
+		if ($string === '') return false;
17 17
 
18
-        $parent_result = parent::validate($string, $config, $context);
19
-        if ($parent_result !== false) return $parent_result;
18
+		$parent_result = parent::validate($string, $config, $context);
19
+		if ($parent_result !== false) return $parent_result;
20 20
 
21
-        $length = strlen($string);
22
-        $last_char = $string[$length - 1];
21
+		$length = strlen($string);
22
+		$last_char = $string[$length - 1];
23 23
 
24
-        if ($last_char !== '%') return false;
24
+		if ($last_char !== '%') return false;
25 25
 
26
-        $points = substr($string, 0, $length - 1);
26
+		$points = substr($string, 0, $length - 1);
27 27
 
28
-        if (!is_numeric($points)) return false;
28
+		if (!is_numeric($points)) return false;
29 29
 
30
-        $points = (int) $points;
30
+		$points = (int) $points;
31 31
 
32
-        if ($points < 0) return '0%';
33
-        if ($points > 100) return '100%';
32
+		if ($points < 0) return '0%';
33
+		if ($points > 100) return '100%';
34 34
 
35
-        return ((string) $points) . '%';
35
+		return ((string) $points) . '%';
36 36
 
37
-    }
37
+	}
38 38
 
39 39
 }
40 40
 
Please login to merge, or discard this patch.
Braces   +18 added lines, -6 removed lines patch added patch discarded remove patch
@@ -13,24 +13,36 @@
 block discarded – undo
13 13
     public function validate($string, $config, $context) {
14 14
 
15 15
         $string = trim($string);
16
-        if ($string === '') return false;
16
+        if ($string === '') {
17
+        	return false;
18
+        }
17 19
 
18 20
         $parent_result = parent::validate($string, $config, $context);
19
-        if ($parent_result !== false) return $parent_result;
21
+        if ($parent_result !== false) {
22
+        	return $parent_result;
23
+        }
20 24
 
21 25
         $length = strlen($string);
22 26
         $last_char = $string[$length - 1];
23 27
 
24
-        if ($last_char !== '%') return false;
28
+        if ($last_char !== '%') {
29
+        	return false;
30
+        }
25 31
 
26 32
         $points = substr($string, 0, $length - 1);
27 33
 
28
-        if (!is_numeric($points)) return false;
34
+        if (!is_numeric($points)) {
35
+        	return false;
36
+        }
29 37
 
30 38
         $points = (int) $points;
31 39
 
32
-        if ($points < 0) return '0%';
33
-        if ($points > 100) return '100%';
40
+        if ($points < 0) {
41
+        	return '0%';
42
+        }
43
+        if ($points > 100) {
44
+        	return '100%';
45
+        }
34 46
 
35 47
         return ((string) $points) . '%';
36 48
 
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -32,7 +32,7 @@
 block discarded – undo
32 32
         if ($points < 0) return '0%';
33 33
         if ($points > 100) return '100%';
34 34
 
35
-        return ((string) $points) . '%';
35
+        return ((string) $points).'%';
36 36
 
37 37
     }
38 38
 
Please login to merge, or discard this patch.
security/htmlpurifier/library/HTMLPurifier/AttrDef/HTML/LinkTypes.php 3 patches
Indentation   +38 added lines, -38 removed lines patch added patch discarded remove patch
@@ -9,44 +9,44 @@
 block discarded – undo
9 9
 class HTMLPurifier_AttrDef_HTML_LinkTypes extends HTMLPurifier_AttrDef
10 10
 {
11 11
 
12
-    /** Name config attribute to pull. */
13
-    protected $name;
14
-
15
-    public function __construct($name) {
16
-        $configLookup = array(
17
-            'rel' => 'AllowedRel',
18
-            'rev' => 'AllowedRev'
19
-        );
20
-        if (!isset($configLookup[$name])) {
21
-            trigger_error('Unrecognized attribute name for link '.
22
-                'relationship.', E_USER_ERROR);
23
-            return;
24
-        }
25
-        $this->name = $configLookup[$name];
26
-    }
27
-
28
-    public function validate($string, $config, $context) {
29
-
30
-        $allowed = $config->get('Attr.' . $this->name);
31
-        if (empty($allowed)) return false;
32
-
33
-        $string = $this->parseCDATA($string);
34
-        $parts = explode(' ', $string);
35
-
36
-        // lookup to prevent duplicates
37
-        $ret_lookup = array();
38
-        foreach ($parts as $part) {
39
-            $part = strtolower(trim($part));
40
-            if (!isset($allowed[$part])) continue;
41
-            $ret_lookup[$part] = true;
42
-        }
43
-
44
-        if (empty($ret_lookup)) return false;
45
-        $string = implode(' ', array_keys($ret_lookup));
46
-
47
-        return $string;
48
-
49
-    }
12
+	/** Name config attribute to pull. */
13
+	protected $name;
14
+
15
+	public function __construct($name) {
16
+		$configLookup = array(
17
+			'rel' => 'AllowedRel',
18
+			'rev' => 'AllowedRev'
19
+		);
20
+		if (!isset($configLookup[$name])) {
21
+			trigger_error('Unrecognized attribute name for link '.
22
+				'relationship.', E_USER_ERROR);
23
+			return;
24
+		}
25
+		$this->name = $configLookup[$name];
26
+	}
27
+
28
+	public function validate($string, $config, $context) {
29
+
30
+		$allowed = $config->get('Attr.' . $this->name);
31
+		if (empty($allowed)) return false;
32
+
33
+		$string = $this->parseCDATA($string);
34
+		$parts = explode(' ', $string);
35
+
36
+		// lookup to prevent duplicates
37
+		$ret_lookup = array();
38
+		foreach ($parts as $part) {
39
+			$part = strtolower(trim($part));
40
+			if (!isset($allowed[$part])) continue;
41
+			$ret_lookup[$part] = true;
42
+		}
43
+
44
+		if (empty($ret_lookup)) return false;
45
+		$string = implode(' ', array_keys($ret_lookup));
46
+
47
+		return $string;
48
+
49
+	}
50 50
 
51 51
 }
52 52
 
Please login to merge, or discard this patch.
Braces   +9 added lines, -3 removed lines patch added patch discarded remove patch
@@ -28,7 +28,9 @@  discard block
 block discarded – undo
28 28
     public function validate($string, $config, $context) {
29 29
 
30 30
         $allowed = $config->get('Attr.' . $this->name);
31
-        if (empty($allowed)) return false;
31
+        if (empty($allowed)) {
32
+        	return false;
33
+        }
32 34
 
33 35
         $string = $this->parseCDATA($string);
34 36
         $parts = explode(' ', $string);
@@ -37,11 +39,15 @@  discard block
 block discarded – undo
37 39
         $ret_lookup = array();
38 40
         foreach ($parts as $part) {
39 41
             $part = strtolower(trim($part));
40
-            if (!isset($allowed[$part])) continue;
42
+            if (!isset($allowed[$part])) {
43
+            	continue;
44
+            }
41 45
             $ret_lookup[$part] = true;
42 46
         }
43 47
 
44
-        if (empty($ret_lookup)) return false;
48
+        if (empty($ret_lookup)) {
49
+        	return false;
50
+        }
45 51
         $string = implode(' ', array_keys($ret_lookup));
46 52
 
47 53
         return $string;
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -27,7 +27,7 @@
 block discarded – undo
27 27
 
28 28
     public function validate($string, $config, $context) {
29 29
 
30
-        $allowed = $config->get('Attr.' . $this->name);
30
+        $allowed = $config->get('Attr.'.$this->name);
31 31
         if (empty($allowed)) return false;
32 32
 
33 33
         $string = $this->parseCDATA($string);
Please login to merge, or discard this patch.
security/htmlpurifier/library/HTMLPurifier/AttrDef/HTML/MultiLength.php 3 patches
Indentation   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -9,32 +9,32 @@
 block discarded – undo
9 9
 class HTMLPurifier_AttrDef_HTML_MultiLength extends HTMLPurifier_AttrDef_HTML_Length
10 10
 {
11 11
 
12
-    public function validate($string, $config, $context) {
12
+	public function validate($string, $config, $context) {
13 13
 
14
-        $string = trim($string);
15
-        if ($string === '') return false;
14
+		$string = trim($string);
15
+		if ($string === '') return false;
16 16
 
17
-        $parent_result = parent::validate($string, $config, $context);
18
-        if ($parent_result !== false) return $parent_result;
17
+		$parent_result = parent::validate($string, $config, $context);
18
+		if ($parent_result !== false) return $parent_result;
19 19
 
20
-        $length = strlen($string);
21
-        $last_char = $string[$length - 1];
20
+		$length = strlen($string);
21
+		$last_char = $string[$length - 1];
22 22
 
23
-        if ($last_char !== '*') return false;
23
+		if ($last_char !== '*') return false;
24 24
 
25
-        $int = substr($string, 0, $length - 1);
25
+		$int = substr($string, 0, $length - 1);
26 26
 
27
-        if ($int == '') return '*';
28
-        if (!is_numeric($int)) return false;
27
+		if ($int == '') return '*';
28
+		if (!is_numeric($int)) return false;
29 29
 
30
-        $int = (int) $int;
30
+		$int = (int) $int;
31 31
 
32
-        if ($int < 0) return false;
33
-        if ($int == 0) return '0';
34
-        if ($int == 1) return '*';
35
-        return ((string) $int) . '*';
32
+		if ($int < 0) return false;
33
+		if ($int == 0) return '0';
34
+		if ($int == 1) return '*';
35
+		return ((string) $int) . '*';
36 36
 
37
-    }
37
+	}
38 38
 
39 39
 }
40 40
 
Please login to merge, or discard this patch.
Braces   +24 added lines, -8 removed lines patch added patch discarded remove patch
@@ -12,26 +12,42 @@
 block discarded – undo
12 12
     public function validate($string, $config, $context) {
13 13
 
14 14
         $string = trim($string);
15
-        if ($string === '') return false;
15
+        if ($string === '') {
16
+        	return false;
17
+        }
16 18
 
17 19
         $parent_result = parent::validate($string, $config, $context);
18
-        if ($parent_result !== false) return $parent_result;
20
+        if ($parent_result !== false) {
21
+        	return $parent_result;
22
+        }
19 23
 
20 24
         $length = strlen($string);
21 25
         $last_char = $string[$length - 1];
22 26
 
23
-        if ($last_char !== '*') return false;
27
+        if ($last_char !== '*') {
28
+        	return false;
29
+        }
24 30
 
25 31
         $int = substr($string, 0, $length - 1);
26 32
 
27
-        if ($int == '') return '*';
28
-        if (!is_numeric($int)) return false;
33
+        if ($int == '') {
34
+        	return '*';
35
+        }
36
+        if (!is_numeric($int)) {
37
+        	return false;
38
+        }
29 39
 
30 40
         $int = (int) $int;
31 41
 
32
-        if ($int < 0) return false;
33
-        if ($int == 0) return '0';
34
-        if ($int == 1) return '*';
42
+        if ($int < 0) {
43
+        	return false;
44
+        }
45
+        if ($int == 0) {
46
+        	return '0';
47
+        }
48
+        if ($int == 1) {
49
+        	return '*';
50
+        }
35 51
         return ((string) $int) . '*';
36 52
 
37 53
     }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -32,7 +32,7 @@
 block discarded – undo
32 32
         if ($int < 0) return false;
33 33
         if ($int == 0) return '0';
34 34
         if ($int == 1) return '*';
35
-        return ((string) $int) . '*';
35
+        return ((string) $int).'*';
36 36
 
37 37
     }
38 38
 
Please login to merge, or discard this patch.
security/htmlpurifier/library/HTMLPurifier/AttrDef/HTML/Nmtokens.php 3 patches
Indentation   +40 added lines, -40 removed lines patch added patch discarded remove patch
@@ -6,46 +6,46 @@
 block discarded – undo
6 6
 class HTMLPurifier_AttrDef_HTML_Nmtokens extends HTMLPurifier_AttrDef
7 7
 {
8 8
 
9
-    public function validate($string, $config, $context) {
10
-
11
-        $string = trim($string);
12
-
13
-        // early abort: '' and '0' (strings that convert to false) are invalid
14
-        if (!$string) return false;
15
-
16
-        $tokens = $this->split($string, $config, $context);
17
-        $tokens = $this->filter($tokens, $config, $context);
18
-        if (empty($tokens)) return false;
19
-        return implode(' ', $tokens);
20
-
21
-    }
22
-
23
-    /**
24
-     * Splits a space separated list of tokens into its constituent parts.
25
-     */
26
-    protected function split($string, $config, $context) {
27
-        // OPTIMIZABLE!
28
-        // do the preg_match, capture all subpatterns for reformulation
29
-
30
-        // we don't support U+00A1 and up codepoints or
31
-        // escaping because I don't know how to do that with regexps
32
-        // and plus it would complicate optimization efforts (you never
33
-        // see that anyway).
34
-        $pattern = '/(?:(?<=\s)|\A)'. // look behind for space or string start
35
-                   '((?:--|-?[A-Za-z_])[A-Za-z_\-0-9]*)'.
36
-                   '(?:(?=\s)|\z)/'; // look ahead for space or string end
37
-        preg_match_all($pattern, $string, $matches);
38
-        return $matches[1];
39
-    }
40
-
41
-    /**
42
-     * Template method for removing certain tokens based on arbitrary criteria.
43
-     * @note If we wanted to be really functional, we'd do an array_filter
44
-     *       with a callback. But... we're not.
45
-     */
46
-    protected function filter($tokens, $config, $context) {
47
-        return $tokens;
48
-    }
9
+	public function validate($string, $config, $context) {
10
+
11
+		$string = trim($string);
12
+
13
+		// early abort: '' and '0' (strings that convert to false) are invalid
14
+		if (!$string) return false;
15
+
16
+		$tokens = $this->split($string, $config, $context);
17
+		$tokens = $this->filter($tokens, $config, $context);
18
+		if (empty($tokens)) return false;
19
+		return implode(' ', $tokens);
20
+
21
+	}
22
+
23
+	/**
24
+	 * Splits a space separated list of tokens into its constituent parts.
25
+	 */
26
+	protected function split($string, $config, $context) {
27
+		// OPTIMIZABLE!
28
+		// do the preg_match, capture all subpatterns for reformulation
29
+
30
+		// we don't support U+00A1 and up codepoints or
31
+		// escaping because I don't know how to do that with regexps
32
+		// and plus it would complicate optimization efforts (you never
33
+		// see that anyway).
34
+		$pattern = '/(?:(?<=\s)|\A)'. // look behind for space or string start
35
+				   '((?:--|-?[A-Za-z_])[A-Za-z_\-0-9]*)'.
36
+				   '(?:(?=\s)|\z)/'; // look ahead for space or string end
37
+		preg_match_all($pattern, $string, $matches);
38
+		return $matches[1];
39
+	}
40
+
41
+	/**
42
+	 * Template method for removing certain tokens based on arbitrary criteria.
43
+	 * @note If we wanted to be really functional, we'd do an array_filter
44
+	 *       with a callback. But... we're not.
45
+	 */
46
+	protected function filter($tokens, $config, $context) {
47
+		return $tokens;
48
+	}
49 49
 
50 50
 }
51 51
 
Please login to merge, or discard this patch.
Braces   +6 added lines, -2 removed lines patch added patch discarded remove patch
@@ -11,11 +11,15 @@
 block discarded – undo
11 11
         $string = trim($string);
12 12
 
13 13
         // early abort: '' and '0' (strings that convert to false) are invalid
14
-        if (!$string) return false;
14
+        if (!$string) {
15
+        	return false;
16
+        }
15 17
 
16 18
         $tokens = $this->split($string, $config, $context);
17 19
         $tokens = $this->filter($tokens, $config, $context);
18
-        if (empty($tokens)) return false;
20
+        if (empty($tokens)) {
21
+        	return false;
22
+        }
19 23
         return implode(' ', $tokens);
20 24
 
21 25
     }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -31,7 +31,7 @@
 block discarded – undo
31 31
         // escaping because I don't know how to do that with regexps
32 32
         // and plus it would complicate optimization efforts (you never
33 33
         // see that anyway).
34
-        $pattern = '/(?:(?<=\s)|\A)'. // look behind for space or string start
34
+        $pattern = '/(?:(?<=\s)|\A)'.// look behind for space or string start
35 35
                    '((?:--|-?[A-Za-z_])[A-Za-z_\-0-9]*)'.
36 36
                    '(?:(?=\s)|\z)/'; // look ahead for space or string end
37 37
         preg_match_all($pattern, $string, $matches);
Please login to merge, or discard this patch.
classes/security/htmlpurifier/library/HTMLPurifier/AttrDef/HTML/Pixels.php 2 patches
Indentation   +27 added lines, -27 removed lines patch added patch discarded remove patch
@@ -6,42 +6,42 @@
 block discarded – undo
6 6
 class HTMLPurifier_AttrDef_HTML_Pixels extends HTMLPurifier_AttrDef
7 7
 {
8 8
 
9
-    protected $max;
9
+	protected $max;
10 10
 
11
-    public function __construct($max = null) {
12
-        $this->max = $max;
13
-    }
11
+	public function __construct($max = null) {
12
+		$this->max = $max;
13
+	}
14 14
 
15
-    public function validate($string, $config, $context) {
15
+	public function validate($string, $config, $context) {
16 16
 
17
-        $string = trim($string);
18
-        if ($string === '0') return $string;
19
-        if ($string === '')  return false;
20
-        $length = strlen($string);
21
-        if (substr($string, $length - 2) == 'px') {
22
-            $string = substr($string, 0, $length - 2);
23
-        }
24
-        if (!is_numeric($string)) return false;
25
-        $int = (int) $string;
17
+		$string = trim($string);
18
+		if ($string === '0') return $string;
19
+		if ($string === '')  return false;
20
+		$length = strlen($string);
21
+		if (substr($string, $length - 2) == 'px') {
22
+			$string = substr($string, 0, $length - 2);
23
+		}
24
+		if (!is_numeric($string)) return false;
25
+		$int = (int) $string;
26 26
 
27
-        if ($int < 0) return '0';
27
+		if ($int < 0) return '0';
28 28
 
29
-        // upper-bound value, extremely high values can
30
-        // crash operating systems, see <http://ha.ckers.org/imagecrash.html>
31
-        // WARNING, above link WILL crash you if you're using Windows
29
+		// upper-bound value, extremely high values can
30
+		// crash operating systems, see <http://ha.ckers.org/imagecrash.html>
31
+		// WARNING, above link WILL crash you if you're using Windows
32 32
 
33
-        if ($this->max !== null && $int > $this->max) return (string) $this->max;
33
+		if ($this->max !== null && $int > $this->max) return (string) $this->max;
34 34
 
35
-        return (string) $int;
35
+		return (string) $int;
36 36
 
37
-    }
37
+	}
38 38
 
39
-    public function make($string) {
40
-        if ($string === '') $max = null;
41
-        else $max = (int) $string;
42
-        $class = get_class($this);
43
-        return new $class($max);
44
-    }
39
+	public function make($string) {
40
+		if ($string === '') $max = null;
41
+		else $max = (int) $string;
42
+		$class = get_class($this);
43
+		return new $class($max);
44
+	}
45 45
 
46 46
 }
47 47
 
Please login to merge, or discard this patch.
Braces   +20 added lines, -7 removed lines patch added patch discarded remove patch
@@ -15,30 +15,43 @@
 block discarded – undo
15 15
     public function validate($string, $config, $context) {
16 16
 
17 17
         $string = trim($string);
18
-        if ($string === '0') return $string;
19
-        if ($string === '')  return false;
18
+        if ($string === '0') {
19
+        	return $string;
20
+        }
21
+        if ($string === '') {
22
+        	return false;
23
+        }
20 24
         $length = strlen($string);
21 25
         if (substr($string, $length - 2) == 'px') {
22 26
             $string = substr($string, 0, $length - 2);
23 27
         }
24
-        if (!is_numeric($string)) return false;
28
+        if (!is_numeric($string)) {
29
+        	return false;
30
+        }
25 31
         $int = (int) $string;
26 32
 
27
-        if ($int < 0) return '0';
33
+        if ($int < 0) {
34
+        	return '0';
35
+        }
28 36
 
29 37
         // upper-bound value, extremely high values can
30 38
         // crash operating systems, see <http://ha.ckers.org/imagecrash.html>
31 39
         // WARNING, above link WILL crash you if you're using Windows
32 40
 
33
-        if ($this->max !== null && $int > $this->max) return (string) $this->max;
41
+        if ($this->max !== null && $int > $this->max) {
42
+        	return (string) $this->max;
43
+        }
34 44
 
35 45
         return (string) $int;
36 46
 
37 47
     }
38 48
 
39 49
     public function make($string) {
40
-        if ($string === '') $max = null;
41
-        else $max = (int) $string;
50
+        if ($string === '') {
51
+        	$max = null;
52
+        } else {
53
+        	$max = (int) $string;
54
+        }
42 55
         $class = get_class($this);
43 56
         return new $class($max);
44 57
     }
Please login to merge, or discard this patch.
classes/security/htmlpurifier/library/HTMLPurifier/AttrDef/Integer.php 3 patches
Indentation   +46 added lines, -46 removed lines patch added patch discarded remove patch
@@ -10,63 +10,63 @@
 block discarded – undo
10 10
 class HTMLPurifier_AttrDef_Integer extends HTMLPurifier_AttrDef
11 11
 {
12 12
 
13
-    /**
14
-     * Bool indicating whether or not negative values are allowed
15
-     */
16
-    protected $negative = true;
13
+	/**
14
+	 * Bool indicating whether or not negative values are allowed
15
+	 */
16
+	protected $negative = true;
17 17
 
18
-    /**
19
-     * Bool indicating whether or not zero is allowed
20
-     */
21
-    protected $zero = true;
18
+	/**
19
+	 * Bool indicating whether or not zero is allowed
20
+	 */
21
+	protected $zero = true;
22 22
 
23
-    /**
24
-     * Bool indicating whether or not positive values are allowed
25
-     */
26
-    protected $positive = true;
23
+	/**
24
+	 * Bool indicating whether or not positive values are allowed
25
+	 */
26
+	protected $positive = true;
27 27
 
28
-    /**
29
-     * @param $negative Bool indicating whether or not negative values are allowed
30
-     * @param $zero Bool indicating whether or not zero is allowed
31
-     * @param $positive Bool indicating whether or not positive values are allowed
32
-     */
33
-    public function __construct(
34
-        $negative = true, $zero = true, $positive = true
35
-    ) {
36
-        $this->negative = $negative;
37
-        $this->zero     = $zero;
38
-        $this->positive = $positive;
39
-    }
28
+	/**
29
+	 * @param $negative Bool indicating whether or not negative values are allowed
30
+	 * @param $zero Bool indicating whether or not zero is allowed
31
+	 * @param $positive Bool indicating whether or not positive values are allowed
32
+	 */
33
+	public function __construct(
34
+		$negative = true, $zero = true, $positive = true
35
+	) {
36
+		$this->negative = $negative;
37
+		$this->zero     = $zero;
38
+		$this->positive = $positive;
39
+	}
40 40
 
41
-    public function validate($integer, $config, $context) {
41
+	public function validate($integer, $config, $context) {
42 42
 
43
-        $integer = $this->parseCDATA($integer);
44
-        if ($integer === '') return false;
43
+		$integer = $this->parseCDATA($integer);
44
+		if ($integer === '') return false;
45 45
 
46
-        // we could possibly simply typecast it to integer, but there are
47
-        // certain fringe cases that must not return an integer.
46
+		// we could possibly simply typecast it to integer, but there are
47
+		// certain fringe cases that must not return an integer.
48 48
 
49
-        // clip leading sign
50
-        if ( $this->negative && $integer[0] === '-' ) {
51
-            $digits = substr($integer, 1);
52
-            if ($digits === '0') $integer = '0'; // rm minus sign for zero
53
-        } elseif( $this->positive && $integer[0] === '+' ) {
54
-            $digits = $integer = substr($integer, 1); // rm unnecessary plus
55
-        } else {
56
-            $digits = $integer;
57
-        }
49
+		// clip leading sign
50
+		if ( $this->negative && $integer[0] === '-' ) {
51
+			$digits = substr($integer, 1);
52
+			if ($digits === '0') $integer = '0'; // rm minus sign for zero
53
+		} elseif( $this->positive && $integer[0] === '+' ) {
54
+			$digits = $integer = substr($integer, 1); // rm unnecessary plus
55
+		} else {
56
+			$digits = $integer;
57
+		}
58 58
 
59
-        // test if it's numeric
60
-        if (!ctype_digit($digits)) return false;
59
+		// test if it's numeric
60
+		if (!ctype_digit($digits)) return false;
61 61
 
62
-        // perform scope tests
63
-        if (!$this->zero     && $integer == 0) return false;
64
-        if (!$this->positive && $integer > 0) return false;
65
-        if (!$this->negative && $integer < 0) return false;
62
+		// perform scope tests
63
+		if (!$this->zero     && $integer == 0) return false;
64
+		if (!$this->positive && $integer > 0) return false;
65
+		if (!$this->negative && $integer < 0) return false;
66 66
 
67
-        return $integer;
67
+		return $integer;
68 68
 
69
-    }
69
+	}
70 70
 
71 71
 }
72 72
 
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -47,10 +47,10 @@  discard block
 block discarded – undo
47 47
         // certain fringe cases that must not return an integer.
48 48
 
49 49
         // clip leading sign
50
-        if ( $this->negative && $integer[0] === '-' ) {
50
+        if ($this->negative && $integer[0] === '-') {
51 51
             $digits = substr($integer, 1);
52 52
             if ($digits === '0') $integer = '0'; // rm minus sign for zero
53
-        } elseif( $this->positive && $integer[0] === '+' ) {
53
+        } elseif ($this->positive && $integer[0] === '+') {
54 54
             $digits = $integer = substr($integer, 1); // rm unnecessary plus
55 55
         } else {
56 56
             $digits = $integer;
@@ -60,7 +60,7 @@  discard block
 block discarded – undo
60 60
         if (!ctype_digit($digits)) return false;
61 61
 
62 62
         // perform scope tests
63
-        if (!$this->zero     && $integer == 0) return false;
63
+        if (!$this->zero && $integer == 0) return false;
64 64
         if (!$this->positive && $integer > 0) return false;
65 65
         if (!$this->negative && $integer < 0) return false;
66 66
 
Please login to merge, or discard this patch.
Braces   +19 added lines, -6 removed lines patch added patch discarded remove patch
@@ -41,7 +41,9 @@  discard block
 block discarded – undo
41 41
     public function validate($integer, $config, $context) {
42 42
 
43 43
         $integer = $this->parseCDATA($integer);
44
-        if ($integer === '') return false;
44
+        if ($integer === '') {
45
+        	return false;
46
+        }
45 47
 
46 48
         // we could possibly simply typecast it to integer, but there are
47 49
         // certain fringe cases that must not return an integer.
@@ -49,7 +51,10 @@  discard block
 block discarded – undo
49 51
         // clip leading sign
50 52
         if ( $this->negative && $integer[0] === '-' ) {
51 53
             $digits = substr($integer, 1);
52
-            if ($digits === '0') $integer = '0'; // rm minus sign for zero
54
+            if ($digits === '0') {
55
+            	$integer = '0';
56
+            }
57
+            // rm minus sign for zero
53 58
         } elseif( $this->positive && $integer[0] === '+' ) {
54 59
             $digits = $integer = substr($integer, 1); // rm unnecessary plus
55 60
         } else {
@@ -57,12 +62,20 @@  discard block
 block discarded – undo
57 62
         }
58 63
 
59 64
         // test if it's numeric
60
-        if (!ctype_digit($digits)) return false;
65
+        if (!ctype_digit($digits)) {
66
+        	return false;
67
+        }
61 68
 
62 69
         // perform scope tests
63
-        if (!$this->zero     && $integer == 0) return false;
64
-        if (!$this->positive && $integer > 0) return false;
65
-        if (!$this->negative && $integer < 0) return false;
70
+        if (!$this->zero     && $integer == 0) {
71
+        	return false;
72
+        }
73
+        if (!$this->positive && $integer > 0) {
74
+        	return false;
75
+        }
76
+        if (!$this->negative && $integer < 0) {
77
+        	return false;
78
+        }
66 79
 
67 80
         return $integer;
68 81
 
Please login to merge, or discard this patch.
classes/security/htmlpurifier/library/HTMLPurifier/AttrDef/Lang.php 3 patches
Indentation   +50 added lines, -50 removed lines patch added patch discarded remove patch
@@ -7,66 +7,66 @@
 block discarded – undo
7 7
 class HTMLPurifier_AttrDef_Lang extends HTMLPurifier_AttrDef
8 8
 {
9 9
 
10
-    public function validate($string, $config, $context) {
10
+	public function validate($string, $config, $context) {
11 11
 
12
-        $string = trim($string);
13
-        if (!$string) return false;
12
+		$string = trim($string);
13
+		if (!$string) return false;
14 14
 
15
-        $subtags = explode('-', $string);
16
-        $num_subtags = count($subtags);
15
+		$subtags = explode('-', $string);
16
+		$num_subtags = count($subtags);
17 17
 
18
-        if ($num_subtags == 0) return false; // sanity check
18
+		if ($num_subtags == 0) return false; // sanity check
19 19
 
20
-        // process primary subtag : $subtags[0]
21
-        $length = strlen($subtags[0]);
22
-        switch ($length) {
23
-            case 0:
24
-                return false;
25
-            case 1:
26
-                if (! ($subtags[0] == 'x' || $subtags[0] == 'i') ) {
27
-                    return false;
28
-                }
29
-                break;
30
-            case 2:
31
-            case 3:
32
-                if (! ctype_alpha($subtags[0]) ) {
33
-                    return false;
34
-                } elseif (! ctype_lower($subtags[0]) ) {
35
-                    $subtags[0] = strtolower($subtags[0]);
36
-                }
37
-                break;
38
-            default:
39
-                return false;
40
-        }
20
+		// process primary subtag : $subtags[0]
21
+		$length = strlen($subtags[0]);
22
+		switch ($length) {
23
+			case 0:
24
+				return false;
25
+			case 1:
26
+				if (! ($subtags[0] == 'x' || $subtags[0] == 'i') ) {
27
+					return false;
28
+				}
29
+				break;
30
+			case 2:
31
+			case 3:
32
+				if (! ctype_alpha($subtags[0]) ) {
33
+					return false;
34
+				} elseif (! ctype_lower($subtags[0]) ) {
35
+					$subtags[0] = strtolower($subtags[0]);
36
+				}
37
+				break;
38
+			default:
39
+				return false;
40
+		}
41 41
 
42
-        $new_string = $subtags[0];
43
-        if ($num_subtags == 1) return $new_string;
42
+		$new_string = $subtags[0];
43
+		if ($num_subtags == 1) return $new_string;
44 44
 
45
-        // process second subtag : $subtags[1]
46
-        $length = strlen($subtags[1]);
47
-        if ($length == 0 || ($length == 1 && $subtags[1] != 'x') || $length > 8 || !ctype_alnum($subtags[1])) {
48
-            return $new_string;
49
-        }
50
-        if (!ctype_lower($subtags[1])) $subtags[1] = strtolower($subtags[1]);
45
+		// process second subtag : $subtags[1]
46
+		$length = strlen($subtags[1]);
47
+		if ($length == 0 || ($length == 1 && $subtags[1] != 'x') || $length > 8 || !ctype_alnum($subtags[1])) {
48
+			return $new_string;
49
+		}
50
+		if (!ctype_lower($subtags[1])) $subtags[1] = strtolower($subtags[1]);
51 51
 
52
-        $new_string .= '-' . $subtags[1];
53
-        if ($num_subtags == 2) return $new_string;
52
+		$new_string .= '-' . $subtags[1];
53
+		if ($num_subtags == 2) return $new_string;
54 54
 
55
-        // process all other subtags, index 2 and up
56
-        for ($i = 2; $i < $num_subtags; $i++) {
57
-            $length = strlen($subtags[$i]);
58
-            if ($length == 0 || $length > 8 || !ctype_alnum($subtags[$i])) {
59
-                return $new_string;
60
-            }
61
-            if (!ctype_lower($subtags[$i])) {
62
-                $subtags[$i] = strtolower($subtags[$i]);
63
-            }
64
-            $new_string .= '-' . $subtags[$i];
65
-        }
55
+		// process all other subtags, index 2 and up
56
+		for ($i = 2; $i < $num_subtags; $i++) {
57
+			$length = strlen($subtags[$i]);
58
+			if ($length == 0 || $length > 8 || !ctype_alnum($subtags[$i])) {
59
+				return $new_string;
60
+			}
61
+			if (!ctype_lower($subtags[$i])) {
62
+				$subtags[$i] = strtolower($subtags[$i]);
63
+			}
64
+			$new_string .= '-' . $subtags[$i];
65
+		}
66 66
 
67
-        return $new_string;
67
+		return $new_string;
68 68
 
69
-    }
69
+	}
70 70
 
71 71
 }
72 72
 
Please login to merge, or discard this patch.
Braces   +16 added lines, -5 removed lines patch added patch discarded remove patch
@@ -10,12 +10,17 @@  discard block
 block discarded – undo
10 10
     public function validate($string, $config, $context) {
11 11
 
12 12
         $string = trim($string);
13
-        if (!$string) return false;
13
+        if (!$string) {
14
+        	return false;
15
+        }
14 16
 
15 17
         $subtags = explode('-', $string);
16 18
         $num_subtags = count($subtags);
17 19
 
18
-        if ($num_subtags == 0) return false; // sanity check
20
+        if ($num_subtags == 0) {
21
+        	return false;
22
+        }
23
+        // sanity check
19 24
 
20 25
         // process primary subtag : $subtags[0]
21 26
         $length = strlen($subtags[0]);
@@ -40,17 +45,23 @@  discard block
 block discarded – undo
40 45
         }
41 46
 
42 47
         $new_string = $subtags[0];
43
-        if ($num_subtags == 1) return $new_string;
48
+        if ($num_subtags == 1) {
49
+        	return $new_string;
50
+        }
44 51
 
45 52
         // process second subtag : $subtags[1]
46 53
         $length = strlen($subtags[1]);
47 54
         if ($length == 0 || ($length == 1 && $subtags[1] != 'x') || $length > 8 || !ctype_alnum($subtags[1])) {
48 55
             return $new_string;
49 56
         }
50
-        if (!ctype_lower($subtags[1])) $subtags[1] = strtolower($subtags[1]);
57
+        if (!ctype_lower($subtags[1])) {
58
+        	$subtags[1] = strtolower($subtags[1]);
59
+        }
51 60
 
52 61
         $new_string .= '-' . $subtags[1];
53
-        if ($num_subtags == 2) return $new_string;
62
+        if ($num_subtags == 2) {
63
+        	return $new_string;
64
+        }
54 65
 
55 66
         // process all other subtags, index 2 and up
56 67
         for ($i = 2; $i < $num_subtags; $i++) {
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -23,15 +23,15 @@  discard block
 block discarded – undo
23 23
             case 0:
24 24
                 return false;
25 25
             case 1:
26
-                if (! ($subtags[0] == 'x' || $subtags[0] == 'i') ) {
26
+                if (!($subtags[0] == 'x' || $subtags[0] == 'i')) {
27 27
                     return false;
28 28
                 }
29 29
                 break;
30 30
             case 2:
31 31
             case 3:
32
-                if (! ctype_alpha($subtags[0]) ) {
32
+                if (!ctype_alpha($subtags[0])) {
33 33
                     return false;
34
-                } elseif (! ctype_lower($subtags[0]) ) {
34
+                } elseif (!ctype_lower($subtags[0])) {
35 35
                     $subtags[0] = strtolower($subtags[0]);
36 36
                 }
37 37
                 break;
@@ -49,7 +49,7 @@  discard block
 block discarded – undo
49 49
         }
50 50
         if (!ctype_lower($subtags[1])) $subtags[1] = strtolower($subtags[1]);
51 51
 
52
-        $new_string .= '-' . $subtags[1];
52
+        $new_string .= '-'.$subtags[1];
53 53
         if ($num_subtags == 2) return $new_string;
54 54
 
55 55
         // process all other subtags, index 2 and up
@@ -61,7 +61,7 @@  discard block
 block discarded – undo
61 61
             if (!ctype_lower($subtags[$i])) {
62 62
                 $subtags[$i] = strtolower($subtags[$i]);
63 63
             }
64
-            $new_string .= '-' . $subtags[$i];
64
+            $new_string .= '-'.$subtags[$i];
65 65
         }
66 66
 
67 67
         return $new_string;
Please login to merge, or discard this patch.
classes/security/htmlpurifier/library/HTMLPurifier/AttrDef/Switch.php 1 patch
Indentation   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -6,28 +6,28 @@
 block discarded – undo
6 6
 class HTMLPurifier_AttrDef_Switch
7 7
 {
8 8
 
9
-    protected $tag;
10
-    protected $withTag, $withoutTag;
9
+	protected $tag;
10
+	protected $withTag, $withoutTag;
11 11
 
12
-    /**
13
-     * @param string $tag Tag name to switch upon
14
-     * @param HTMLPurifier_AttrDef $with_tag Call if token matches tag
15
-     * @param HTMLPurifier_AttrDef $without_tag Call if token doesn't match, or there is no token
16
-     */
17
-    public function __construct($tag, $with_tag, $without_tag) {
18
-        $this->tag = $tag;
19
-        $this->withTag = $with_tag;
20
-        $this->withoutTag = $without_tag;
21
-    }
12
+	/**
13
+	 * @param string $tag Tag name to switch upon
14
+	 * @param HTMLPurifier_AttrDef $with_tag Call if token matches tag
15
+	 * @param HTMLPurifier_AttrDef $without_tag Call if token doesn't match, or there is no token
16
+	 */
17
+	public function __construct($tag, $with_tag, $without_tag) {
18
+		$this->tag = $tag;
19
+		$this->withTag = $with_tag;
20
+		$this->withoutTag = $without_tag;
21
+	}
22 22
 
23
-    public function validate($string, $config, $context) {
24
-        $token = $context->get('CurrentToken', true);
25
-        if (!$token || $token->name !== $this->tag) {
26
-            return $this->withoutTag->validate($string, $config, $context);
27
-        } else {
28
-            return $this->withTag->validate($string, $config, $context);
29
-        }
30
-    }
23
+	public function validate($string, $config, $context) {
24
+		$token = $context->get('CurrentToken', true);
25
+		if (!$token || $token->name !== $this->tag) {
26
+			return $this->withoutTag->validate($string, $config, $context);
27
+		} else {
28
+			return $this->withTag->validate($string, $config, $context);
29
+		}
30
+	}
31 31
 
32 32
 }
33 33
 
Please login to merge, or discard this patch.