Completed
Branch fix/kses-1 (fea4d9)
by
unknown
02:29 queued 10s
created
core/services/request/sanitizers/AllowedTags.php 1 patch
Indentation   +223 added lines, -223 removed lines patch added patch discarded remove patch
@@ -13,227 +13,227 @@
 block discarded – undo
13 13
 class AllowedTags
14 14
 {
15 15
 
16
-    /**
17
-     * @var array[]
18
-     */
19
-    private static $attributes = [
20
-        'accept-charset'    => 1,
21
-        'action'            => 1,
22
-        'alt'               => 1,
23
-        'allow'             => 1,
24
-        'allowfullscreen'   => 1,
25
-        'align'             => 1,
26
-        'aria-*'            => 1,
27
-        'autocomplete'      => 1,
28
-        'checked'           => 1,
29
-        'class'             => 1,
30
-        'cols'              => 1,
31
-        'content'           => 1,
32
-        'data-*'            => 1,
33
-        'dir'               => 1,
34
-        'disabled'          => 1,
35
-        'enctype'           => 1,
36
-        'for'               => 1,
37
-        'frameborder'       => 1,
38
-        'height'            => 1,
39
-        'href'              => 1,
40
-        'id'                => 1,
41
-        'itemprop'          => 1,
42
-        'itemscope'         => 1,
43
-        'itemtype'          => 1,
44
-        'label'             => 1,
45
-        'lang'              => 1,
46
-        'max'               => 1,
47
-        'maxlength'         => 1,
48
-        'method'            => 1,
49
-        'min'               => 1,
50
-        'multiple'          => 1,
51
-        'name'              => 1,
52
-        'novalidate'        => 1,
53
-        'placeholder'       => 1,
54
-        'readonly'          => 1,
55
-        'rel'               => 1,
56
-        'required'          => 1,
57
-        'rows'              => 1,
58
-        'selected'          => 1,
59
-        'src'               => 1,
60
-        'size'              => 1,
61
-        'style'             => 1,
62
-        'step'              => 1,
63
-        'tabindex'          => 1,
64
-        'target'            => 1,
65
-        'title'             => 1,
66
-        'type'              => 1,
67
-        'value'             => 1,
68
-        'width'             => 1,
69
-    ];
70
-
71
-
72
-    /**
73
-     * @var array
74
-     */
75
-    private static $tags = [
76
-        'a',
77
-        'abbr',
78
-        'b',
79
-        'br',
80
-        'code',
81
-        'div',
82
-        'em',
83
-        'h1',
84
-        'h2',
85
-        'h3',
86
-        'h4',
87
-        'h5',
88
-        'h6',
89
-        'hr',
90
-        'i',
91
-        'img',
92
-        'li',
93
-        'ol',
94
-        'p',
95
-        'pre',
96
-        'small',
97
-        'span',
98
-        'strong',
99
-        'table',
100
-        'td',
101
-        'tr',
102
-        'ul',
103
-    ];
104
-
105
-
106
-    /**
107
-     * @var array
108
-     */
109
-    private static $allowed_tags;
110
-
111
-
112
-    /**
113
-     * @var array
114
-     */
115
-    private static $allowed_with_embed_tags;
116
-
117
-
118
-    /**
119
-     * @var array
120
-     */
121
-    private static $allowed_with_form_tags;
122
-
123
-
124
-    /**
125
-     * @var array
126
-     */
127
-    private static $allowed_with_script_and_style_tags;
128
-
129
-
130
-    /**
131
-     * merges additional tags and attributes into the WP post tags
132
-     */
133
-    private static function initializeAllowedTags()
134
-    {
135
-        $allowed_post_tags = wp_kses_allowed_html('post');
136
-        $allowed_tags = [];
137
-        foreach (AllowedTags::$tags as $tag) {
138
-            $allowed_tags[ $tag ] = AllowedTags::$attributes;
139
-        }
140
-        AllowedTags::$allowed_tags = array_merge_recursive($allowed_post_tags, $allowed_tags);
141
-    }
142
-
143
-
144
-    /**
145
-     * merges embed tags and attributes into the EE all tags
146
-     */
147
-    private static function initializeWithEmbedTags()
148
-    {
149
-        $all_tags = AllowedTags::getAllowedTags();
150
-        $embed_tags = [
151
-            'iframe' => AllowedTags::$attributes
152
-        ];
153
-        AllowedTags::$allowed_with_embed_tags = array_merge_recursive($all_tags, $embed_tags);
154
-    }
155
-
156
-
157
-    /**
158
-     * merges form tags and attributes into the EE all tags
159
-     */
160
-    private static function initializeWithFormTags()
161
-    {
162
-        $all_tags = AllowedTags::getAllowedTags();
163
-        $form_tags = [
164
-            'form' => AllowedTags::$attributes,
165
-            'label' => AllowedTags::$attributes,
166
-            'input' => AllowedTags::$attributes,
167
-            'select' => AllowedTags::$attributes,
168
-            'option' => AllowedTags::$attributes,
169
-            'optgroup' => AllowedTags::$attributes,
170
-            'textarea' => AllowedTags::$attributes,
171
-            'button' => AllowedTags::$attributes,
172
-            'fieldset' => AllowedTags::$attributes,
173
-            'output' => AllowedTags::$attributes,
174
-        ];
175
-        AllowedTags::$allowed_with_form_tags = array_merge_recursive($all_tags, $form_tags);
176
-    }
177
-
178
-
179
-    /**
180
-     * merges form script and style tags and attributes into the EE all tags
181
-     */
182
-    private static function initializeWithScriptAndStyleTags()
183
-    {
184
-        $all_tags = AllowedTags::getAllowedTags();
185
-        $script_and_style_tags = [
186
-            'script' => AllowedTags::$attributes,
187
-            'style' => AllowedTags::$attributes,
188
-        ];
189
-        AllowedTags::$allowed_with_script_and_style_tags = array_merge_recursive($all_tags, $script_and_style_tags);
190
-    }
191
-
192
-
193
-    /**
194
-     * @return array[]
195
-     */
196
-    public static function getAllowedTags()
197
-    {
198
-        if (empty(AllowedTags::$allowed_tags)) {
199
-            AllowedTags::initializeAllowedTags();
200
-        }
201
-        return AllowedTags::$allowed_tags;
202
-    }
203
-
204
-
205
-    /**
206
-     * @return array[]
207
-     */
208
-    public static function getWithEmbedTags()
209
-    {
210
-        if (empty(AllowedTags::$allowed_with_embed_tags)) {
211
-            AllowedTags::initializeWithEmbedTags();
212
-        }
213
-        return AllowedTags::$allowed_with_embed_tags;
214
-    }
215
-
216
-
217
-    /**
218
-     * @return array[]
219
-     */
220
-    public static function getWithFormTags()
221
-    {
222
-        if (empty(AllowedTags::$allowed_with_form_tags)) {
223
-            AllowedTags::initializeWithFormTags();
224
-        }
225
-        return AllowedTags::$allowed_with_form_tags;
226
-    }
227
-
228
-
229
-    /**
230
-     * @return array[]
231
-     */
232
-    public static function getWithScriptAndStyleTags()
233
-    {
234
-        if (empty(AllowedTags::$allowed_with_script_and_style_tags)) {
235
-            AllowedTags::initializeWithScriptAndStyleTags();
236
-        }
237
-        return AllowedTags::$allowed_with_script_and_style_tags;
238
-    }
16
+	/**
17
+	 * @var array[]
18
+	 */
19
+	private static $attributes = [
20
+		'accept-charset'    => 1,
21
+		'action'            => 1,
22
+		'alt'               => 1,
23
+		'allow'             => 1,
24
+		'allowfullscreen'   => 1,
25
+		'align'             => 1,
26
+		'aria-*'            => 1,
27
+		'autocomplete'      => 1,
28
+		'checked'           => 1,
29
+		'class'             => 1,
30
+		'cols'              => 1,
31
+		'content'           => 1,
32
+		'data-*'            => 1,
33
+		'dir'               => 1,
34
+		'disabled'          => 1,
35
+		'enctype'           => 1,
36
+		'for'               => 1,
37
+		'frameborder'       => 1,
38
+		'height'            => 1,
39
+		'href'              => 1,
40
+		'id'                => 1,
41
+		'itemprop'          => 1,
42
+		'itemscope'         => 1,
43
+		'itemtype'          => 1,
44
+		'label'             => 1,
45
+		'lang'              => 1,
46
+		'max'               => 1,
47
+		'maxlength'         => 1,
48
+		'method'            => 1,
49
+		'min'               => 1,
50
+		'multiple'          => 1,
51
+		'name'              => 1,
52
+		'novalidate'        => 1,
53
+		'placeholder'       => 1,
54
+		'readonly'          => 1,
55
+		'rel'               => 1,
56
+		'required'          => 1,
57
+		'rows'              => 1,
58
+		'selected'          => 1,
59
+		'src'               => 1,
60
+		'size'              => 1,
61
+		'style'             => 1,
62
+		'step'              => 1,
63
+		'tabindex'          => 1,
64
+		'target'            => 1,
65
+		'title'             => 1,
66
+		'type'              => 1,
67
+		'value'             => 1,
68
+		'width'             => 1,
69
+	];
70
+
71
+
72
+	/**
73
+	 * @var array
74
+	 */
75
+	private static $tags = [
76
+		'a',
77
+		'abbr',
78
+		'b',
79
+		'br',
80
+		'code',
81
+		'div',
82
+		'em',
83
+		'h1',
84
+		'h2',
85
+		'h3',
86
+		'h4',
87
+		'h5',
88
+		'h6',
89
+		'hr',
90
+		'i',
91
+		'img',
92
+		'li',
93
+		'ol',
94
+		'p',
95
+		'pre',
96
+		'small',
97
+		'span',
98
+		'strong',
99
+		'table',
100
+		'td',
101
+		'tr',
102
+		'ul',
103
+	];
104
+
105
+
106
+	/**
107
+	 * @var array
108
+	 */
109
+	private static $allowed_tags;
110
+
111
+
112
+	/**
113
+	 * @var array
114
+	 */
115
+	private static $allowed_with_embed_tags;
116
+
117
+
118
+	/**
119
+	 * @var array
120
+	 */
121
+	private static $allowed_with_form_tags;
122
+
123
+
124
+	/**
125
+	 * @var array
126
+	 */
127
+	private static $allowed_with_script_and_style_tags;
128
+
129
+
130
+	/**
131
+	 * merges additional tags and attributes into the WP post tags
132
+	 */
133
+	private static function initializeAllowedTags()
134
+	{
135
+		$allowed_post_tags = wp_kses_allowed_html('post');
136
+		$allowed_tags = [];
137
+		foreach (AllowedTags::$tags as $tag) {
138
+			$allowed_tags[ $tag ] = AllowedTags::$attributes;
139
+		}
140
+		AllowedTags::$allowed_tags = array_merge_recursive($allowed_post_tags, $allowed_tags);
141
+	}
142
+
143
+
144
+	/**
145
+	 * merges embed tags and attributes into the EE all tags
146
+	 */
147
+	private static function initializeWithEmbedTags()
148
+	{
149
+		$all_tags = AllowedTags::getAllowedTags();
150
+		$embed_tags = [
151
+			'iframe' => AllowedTags::$attributes
152
+		];
153
+		AllowedTags::$allowed_with_embed_tags = array_merge_recursive($all_tags, $embed_tags);
154
+	}
155
+
156
+
157
+	/**
158
+	 * merges form tags and attributes into the EE all tags
159
+	 */
160
+	private static function initializeWithFormTags()
161
+	{
162
+		$all_tags = AllowedTags::getAllowedTags();
163
+		$form_tags = [
164
+			'form' => AllowedTags::$attributes,
165
+			'label' => AllowedTags::$attributes,
166
+			'input' => AllowedTags::$attributes,
167
+			'select' => AllowedTags::$attributes,
168
+			'option' => AllowedTags::$attributes,
169
+			'optgroup' => AllowedTags::$attributes,
170
+			'textarea' => AllowedTags::$attributes,
171
+			'button' => AllowedTags::$attributes,
172
+			'fieldset' => AllowedTags::$attributes,
173
+			'output' => AllowedTags::$attributes,
174
+		];
175
+		AllowedTags::$allowed_with_form_tags = array_merge_recursive($all_tags, $form_tags);
176
+	}
177
+
178
+
179
+	/**
180
+	 * merges form script and style tags and attributes into the EE all tags
181
+	 */
182
+	private static function initializeWithScriptAndStyleTags()
183
+	{
184
+		$all_tags = AllowedTags::getAllowedTags();
185
+		$script_and_style_tags = [
186
+			'script' => AllowedTags::$attributes,
187
+			'style' => AllowedTags::$attributes,
188
+		];
189
+		AllowedTags::$allowed_with_script_and_style_tags = array_merge_recursive($all_tags, $script_and_style_tags);
190
+	}
191
+
192
+
193
+	/**
194
+	 * @return array[]
195
+	 */
196
+	public static function getAllowedTags()
197
+	{
198
+		if (empty(AllowedTags::$allowed_tags)) {
199
+			AllowedTags::initializeAllowedTags();
200
+		}
201
+		return AllowedTags::$allowed_tags;
202
+	}
203
+
204
+
205
+	/**
206
+	 * @return array[]
207
+	 */
208
+	public static function getWithEmbedTags()
209
+	{
210
+		if (empty(AllowedTags::$allowed_with_embed_tags)) {
211
+			AllowedTags::initializeWithEmbedTags();
212
+		}
213
+		return AllowedTags::$allowed_with_embed_tags;
214
+	}
215
+
216
+
217
+	/**
218
+	 * @return array[]
219
+	 */
220
+	public static function getWithFormTags()
221
+	{
222
+		if (empty(AllowedTags::$allowed_with_form_tags)) {
223
+			AllowedTags::initializeWithFormTags();
224
+		}
225
+		return AllowedTags::$allowed_with_form_tags;
226
+	}
227
+
228
+
229
+	/**
230
+	 * @return array[]
231
+	 */
232
+	public static function getWithScriptAndStyleTags()
233
+	{
234
+		if (empty(AllowedTags::$allowed_with_script_and_style_tags)) {
235
+			AllowedTags::initializeWithScriptAndStyleTags();
236
+		}
237
+		return AllowedTags::$allowed_with_script_and_style_tags;
238
+	}
239 239
 }
Please login to merge, or discard this patch.