@@ -26,13 +26,13 @@ |
||
26 | 26 | |
27 | 27 | public function prepareHtml() |
28 | 28 | { |
29 | - return array_map(function ($v) { |
|
29 | + return array_map(function($v) { |
|
30 | 30 | return is_array($v) ? $v[1] : $v; |
31 | 31 | }, $this->prepocessed->getHTML()); |
32 | 32 | } |
33 | 33 | public function preparePhp() |
34 | 34 | { |
35 | - return array_map(function ($v) { |
|
35 | + return array_map(function($v) { |
|
36 | 36 | return is_array($v)&&($v[0]===T_OPEN_TAG||$v[0]===T_CLOSE_TAG) ? ($v[0]===T_OPEN_TAG ? '<php>' : '</php>') : (is_array($v) ? $v[1] : $v); |
37 | 37 | }, $this->prepocessed->getPHP()); |
38 | 38 | } |
@@ -22,9 +22,9 @@ |
||
22 | 22 | var_dump((bool)stripos($hstrip->go(htmlStrip::ATTRIBUTES), 'src')); //false |
23 | 23 | |
24 | 24 | |
25 | -$hstrip=new htmlStrip($data, 'replace', array('',true), array('src',false)); |
|
26 | -var_dump((bool)stripos($hstrip->go(htmlStrip::ATTRIBUTES), ' type'));//false |
|
27 | -var_dump((bool)stripos($hstrip->go(htmlStrip::ATTRIBUTES), 'src'));//true; |
|
25 | +$hstrip=new htmlStrip($data, 'replace', array('', true), array('src', false)); |
|
26 | +var_dump((bool)stripos($hstrip->go(htmlStrip::ATTRIBUTES), ' type')); //false |
|
27 | +var_dump((bool)stripos($hstrip->go(htmlStrip::ATTRIBUTES), 'src')); //true; |
|
28 | 28 | |
29 | 29 | $hstrip=new htmlStrip($data, 'replace', array('<doctypetag>', true)); |
30 | 30 | $hstrip1=new htmlStrip($data, 'replace', array('<!doctype>', true)); |
@@ -17,363 +17,363 @@ |
||
17 | 17 | protected $head; |
18 | 18 | protected $html_tag; |
19 | 19 | protected static $events_attributes=array( |
20 | - 'onabort' => 1, |
|
21 | - 'onafterprint' => 1, |
|
22 | - 'onbeforeprint' => 1, |
|
23 | - 'onbeforeunload' => 1, |
|
24 | - 'onblur' => 1, |
|
25 | - 'oncanplay' => 1, |
|
26 | - 'oncanplaythrough' => 1, |
|
27 | - 'onchange' => 1, |
|
28 | - 'onclick' => 1, |
|
29 | - 'oncontextmenu' => 1, |
|
30 | - 'oncopy' => 1, |
|
31 | - 'oncuechange' => 1, |
|
32 | - 'oncut' => 1, |
|
33 | - 'ondblclick' => 1, |
|
34 | - 'ondrag' => 1, |
|
35 | - 'ondragend' => 1, |
|
36 | - 'ondragenter' => 1, |
|
37 | - 'ondragleave' => 1, |
|
38 | - 'ondragover' => 1, |
|
39 | - 'ondragstart' => 1, |
|
40 | - 'ondrop' => 1, |
|
41 | - 'ondurationchange' => 1, |
|
42 | - 'onemptied' => 1, |
|
43 | - 'onended' => 1, |
|
44 | - 'onerror' => 1, |
|
45 | - 'onfocus' => 1, |
|
46 | - 'onhashchange' => 1, |
|
47 | - 'oninput' => 1, |
|
48 | - 'oninvalid' => 1, |
|
49 | - 'onkeydown' => 1, |
|
50 | - 'onkeypress' => 1, |
|
51 | - 'onkeyup' => 1, |
|
52 | - 'onload' => 1, |
|
53 | - 'onloadeddata' => 1, |
|
54 | - 'onloadedmetadata' => 1, |
|
55 | - 'onloadstart' => 1, |
|
56 | - 'onmousedown' => 1, |
|
57 | - 'onmousemove' => 1, |
|
58 | - 'onmouseout' => 1, |
|
59 | - 'onmouseover' => 1, |
|
60 | - 'onmouseup' => 1, |
|
61 | - 'onmousewheel' => 1, |
|
62 | - 'onoffline' => 1, |
|
63 | - 'ononline' => 1, |
|
64 | - 'onpageshow' => 1, |
|
65 | - 'onpaste' => 1, |
|
66 | - 'onpause' => 1, |
|
67 | - 'onplay' => 1, |
|
68 | - 'onplaying' => 1, |
|
69 | - 'onprogress' => 1, |
|
70 | - 'onratechange' => 1, |
|
71 | - 'onreset' => 1, |
|
72 | - 'onresize' => 1, |
|
73 | - 'onscroll' => 1, |
|
74 | - 'onsearch' => 1, |
|
75 | - 'onseeked' => 1, |
|
76 | - 'onseeking' => 1, |
|
77 | - 'onselect' => 1, |
|
78 | - 'onstalled' => 1, |
|
79 | - 'onsubmit' => 1, |
|
80 | - 'onsuspend' => 1, |
|
81 | - 'ontimeupdate' => 1, |
|
82 | - 'ontoggle' => 1, |
|
83 | - 'onunload' => 1, |
|
84 | - 'onvolumechange' => 1, |
|
85 | - 'onwaiting' => 1, |
|
86 | - 'onwheel' => 1 |
|
87 | - ); |
|
20 | + 'onabort' => 1, |
|
21 | + 'onafterprint' => 1, |
|
22 | + 'onbeforeprint' => 1, |
|
23 | + 'onbeforeunload' => 1, |
|
24 | + 'onblur' => 1, |
|
25 | + 'oncanplay' => 1, |
|
26 | + 'oncanplaythrough' => 1, |
|
27 | + 'onchange' => 1, |
|
28 | + 'onclick' => 1, |
|
29 | + 'oncontextmenu' => 1, |
|
30 | + 'oncopy' => 1, |
|
31 | + 'oncuechange' => 1, |
|
32 | + 'oncut' => 1, |
|
33 | + 'ondblclick' => 1, |
|
34 | + 'ondrag' => 1, |
|
35 | + 'ondragend' => 1, |
|
36 | + 'ondragenter' => 1, |
|
37 | + 'ondragleave' => 1, |
|
38 | + 'ondragover' => 1, |
|
39 | + 'ondragstart' => 1, |
|
40 | + 'ondrop' => 1, |
|
41 | + 'ondurationchange' => 1, |
|
42 | + 'onemptied' => 1, |
|
43 | + 'onended' => 1, |
|
44 | + 'onerror' => 1, |
|
45 | + 'onfocus' => 1, |
|
46 | + 'onhashchange' => 1, |
|
47 | + 'oninput' => 1, |
|
48 | + 'oninvalid' => 1, |
|
49 | + 'onkeydown' => 1, |
|
50 | + 'onkeypress' => 1, |
|
51 | + 'onkeyup' => 1, |
|
52 | + 'onload' => 1, |
|
53 | + 'onloadeddata' => 1, |
|
54 | + 'onloadedmetadata' => 1, |
|
55 | + 'onloadstart' => 1, |
|
56 | + 'onmousedown' => 1, |
|
57 | + 'onmousemove' => 1, |
|
58 | + 'onmouseout' => 1, |
|
59 | + 'onmouseover' => 1, |
|
60 | + 'onmouseup' => 1, |
|
61 | + 'onmousewheel' => 1, |
|
62 | + 'onoffline' => 1, |
|
63 | + 'ononline' => 1, |
|
64 | + 'onpageshow' => 1, |
|
65 | + 'onpaste' => 1, |
|
66 | + 'onpause' => 1, |
|
67 | + 'onplay' => 1, |
|
68 | + 'onplaying' => 1, |
|
69 | + 'onprogress' => 1, |
|
70 | + 'onratechange' => 1, |
|
71 | + 'onreset' => 1, |
|
72 | + 'onresize' => 1, |
|
73 | + 'onscroll' => 1, |
|
74 | + 'onsearch' => 1, |
|
75 | + 'onseeked' => 1, |
|
76 | + 'onseeking' => 1, |
|
77 | + 'onselect' => 1, |
|
78 | + 'onstalled' => 1, |
|
79 | + 'onsubmit' => 1, |
|
80 | + 'onsuspend' => 1, |
|
81 | + 'ontimeupdate' => 1, |
|
82 | + 'ontoggle' => 1, |
|
83 | + 'onunload' => 1, |
|
84 | + 'onvolumechange' => 1, |
|
85 | + 'onwaiting' => 1, |
|
86 | + 'onwheel' => 1 |
|
87 | + ); |
|
88 | 88 | |
89 | 89 | protected static $attributes=array( |
90 | - 'accept' => 1, |
|
91 | - 'accesskey' => 1, |
|
92 | - 'action' => 1, |
|
93 | - 'alt' => 1, |
|
94 | - 'async' => 1, |
|
95 | - 'autocomplete' => 1, |
|
96 | - 'autofocus' => 1, |
|
97 | - 'autoplay' => 1, |
|
98 | - 'charset' => 1, |
|
99 | - 'checked' => 1, |
|
100 | - 'cite' => 1, |
|
101 | - 'class' => 1, |
|
102 | - 'cols' => 1, |
|
103 | - 'colspan' => 1, |
|
104 | - 'content' => 1, |
|
105 | - 'contenteditable' => 1, |
|
106 | - 'controls' => 1, |
|
107 | - 'coords' => 1, |
|
108 | - 'data' => 1, |
|
109 | - 'datetime' => 1, |
|
110 | - 'default' => 1, |
|
111 | - 'defer' => 1, |
|
112 | - 'dir' => 1, |
|
113 | - 'dirname' => 1, |
|
114 | - 'disabled' => 1, |
|
115 | - 'download' => 1, |
|
116 | - 'draggable' => 1, |
|
117 | - 'dropzone' => 1, |
|
118 | - 'enctype' => 1, |
|
119 | - 'for' => 1, |
|
120 | - 'form' => 1, |
|
121 | - 'formaction' => 1, |
|
122 | - 'headers' => 1, |
|
123 | - 'height' => 1, |
|
124 | - 'hidden' => 1, |
|
125 | - 'high' => 1, |
|
126 | - 'href' => 1, |
|
127 | - 'hreflang' => 1, |
|
128 | - 'http' => 1, |
|
129 | - 'id' => 1, |
|
130 | - 'ismap' => 1, |
|
131 | - 'kind' => 1, |
|
132 | - 'label' => 1, |
|
133 | - 'lang' => 1, |
|
134 | - 'list' => 1, |
|
135 | - 'loop' => 1, |
|
136 | - 'low' => 1, |
|
137 | - 'max' => 1, |
|
138 | - 'maxlength' => 1, |
|
139 | - 'media' => 1, |
|
140 | - 'method' => 1, |
|
141 | - 'min' => 1, |
|
142 | - 'multiple' => 1, |
|
143 | - 'muted' => 1, |
|
144 | - 'name' => 1, |
|
145 | - 'novalidate' => 1, |
|
146 | - 'onabort' => 1, |
|
147 | - 'onafterprint' => 1, |
|
148 | - 'onbeforeprint' => 1, |
|
149 | - 'onbeforeunload' => 1, |
|
150 | - 'onblur' => 1, |
|
151 | - 'oncanplay' => 1, |
|
152 | - 'oncanplaythrough' => 1, |
|
153 | - 'onchange' => 1, |
|
154 | - 'onclick' => 1, |
|
155 | - 'oncontextmenu' => 1, |
|
156 | - 'oncopy' => 1, |
|
157 | - 'oncuechange' => 1, |
|
158 | - 'oncut' => 1, |
|
159 | - 'ondblclick' => 1, |
|
160 | - 'ondrag' => 1, |
|
161 | - 'ondragend' => 1, |
|
162 | - 'ondragenter' => 1, |
|
163 | - 'ondragleave' => 1, |
|
164 | - 'ondragover' => 1, |
|
165 | - 'ondragstart' => 1, |
|
166 | - 'ondrop' => 1, |
|
167 | - 'ondurationchange' => 1, |
|
168 | - 'onemptied' => 1, |
|
169 | - 'onended' => 1, |
|
170 | - 'onerror' => 1, |
|
171 | - 'onfocus' => 1, |
|
172 | - 'onhashchange' => 1, |
|
173 | - 'oninput' => 1, |
|
174 | - 'oninvalid' => 1, |
|
175 | - 'onkeydown' => 1, |
|
176 | - 'onkeypress' => 1, |
|
177 | - 'onkeyup' => 1, |
|
178 | - 'onload' => 1, |
|
179 | - 'onloadeddata' => 1, |
|
180 | - 'onloadedmetadata' => 1, |
|
181 | - 'onloadstart' => 1, |
|
182 | - 'onmousedown' => 1, |
|
183 | - 'onmousemove' => 1, |
|
184 | - 'onmouseout' => 1, |
|
185 | - 'onmouseover' => 1, |
|
186 | - 'onmouseup' => 1, |
|
187 | - 'onmousewheel' => 1, |
|
188 | - 'onoffline' => 1, |
|
189 | - 'ononline' => 1, |
|
190 | - 'onpageshow' => 1, |
|
191 | - 'onpaste' => 1, |
|
192 | - 'onpause' => 1, |
|
193 | - 'onplay' => 1, |
|
194 | - 'onplaying' => 1, |
|
195 | - 'onprogress' => 1, |
|
196 | - 'onratechange' => 1, |
|
197 | - 'onreset' => 1, |
|
198 | - 'onresize' => 1, |
|
199 | - 'onscroll' => 1, |
|
200 | - 'onsearch' => 1, |
|
201 | - 'onseeked' => 1, |
|
202 | - 'onseeking' => 1, |
|
203 | - 'onselect' => 1, |
|
204 | - 'onstalled' => 1, |
|
205 | - 'onsubmit' => 1, |
|
206 | - 'onsuspend' => 1, |
|
207 | - 'ontimeupdate' => 1, |
|
208 | - 'ontoggle' => 1, |
|
209 | - 'onunload' => 1, |
|
210 | - 'onvolumechange' => 1, |
|
211 | - 'onwaiting' => 1, |
|
212 | - 'onwheel' => 1, |
|
213 | - 'open' => 1, |
|
214 | - 'optimum' => 1, |
|
215 | - 'pattern' => 1, |
|
216 | - 'placeholder' => 1, |
|
217 | - 'poster' => 1, |
|
218 | - 'preload' => 1, |
|
219 | - 'readonly' => 1, |
|
220 | - 'rel' => 1, |
|
221 | - 'required' => 1, |
|
222 | - 'reversed' => 1, |
|
223 | - 'rows' => 1, |
|
224 | - 'rowspan' => 1, |
|
225 | - 'sandbox' => 1, |
|
226 | - 'scope' => 1, |
|
227 | - 'selected' => 1, |
|
228 | - 'shape' => 1, |
|
229 | - 'size' => 1, |
|
230 | - 'sizes' => 1, |
|
231 | - 'span' => 1, |
|
232 | - 'spellcheck' => 1, |
|
233 | - 'src' => 1, |
|
234 | - 'srcdoc' => 1, |
|
235 | - 'srclang' => 1, |
|
236 | - 'source' => 1, |
|
237 | - 'start' => 1, |
|
238 | - 'step' => 1, |
|
239 | - 'style' => 1, |
|
240 | - 'tabindex' => 1, |
|
241 | - 'target' => 1, |
|
242 | - 'title' => 1, |
|
243 | - 'translate' => 1, |
|
244 | - 'type' => 1, |
|
245 | - 'usemap' => 1, |
|
246 | - 'value' => 1, |
|
247 | - 'width' => 1, |
|
248 | - 'wrap' => 1, |
|
90 | + 'accept' => 1, |
|
91 | + 'accesskey' => 1, |
|
92 | + 'action' => 1, |
|
93 | + 'alt' => 1, |
|
94 | + 'async' => 1, |
|
95 | + 'autocomplete' => 1, |
|
96 | + 'autofocus' => 1, |
|
97 | + 'autoplay' => 1, |
|
98 | + 'charset' => 1, |
|
99 | + 'checked' => 1, |
|
100 | + 'cite' => 1, |
|
101 | + 'class' => 1, |
|
102 | + 'cols' => 1, |
|
103 | + 'colspan' => 1, |
|
104 | + 'content' => 1, |
|
105 | + 'contenteditable' => 1, |
|
106 | + 'controls' => 1, |
|
107 | + 'coords' => 1, |
|
108 | + 'data' => 1, |
|
109 | + 'datetime' => 1, |
|
110 | + 'default' => 1, |
|
111 | + 'defer' => 1, |
|
112 | + 'dir' => 1, |
|
113 | + 'dirname' => 1, |
|
114 | + 'disabled' => 1, |
|
115 | + 'download' => 1, |
|
116 | + 'draggable' => 1, |
|
117 | + 'dropzone' => 1, |
|
118 | + 'enctype' => 1, |
|
119 | + 'for' => 1, |
|
120 | + 'form' => 1, |
|
121 | + 'formaction' => 1, |
|
122 | + 'headers' => 1, |
|
123 | + 'height' => 1, |
|
124 | + 'hidden' => 1, |
|
125 | + 'high' => 1, |
|
126 | + 'href' => 1, |
|
127 | + 'hreflang' => 1, |
|
128 | + 'http' => 1, |
|
129 | + 'id' => 1, |
|
130 | + 'ismap' => 1, |
|
131 | + 'kind' => 1, |
|
132 | + 'label' => 1, |
|
133 | + 'lang' => 1, |
|
134 | + 'list' => 1, |
|
135 | + 'loop' => 1, |
|
136 | + 'low' => 1, |
|
137 | + 'max' => 1, |
|
138 | + 'maxlength' => 1, |
|
139 | + 'media' => 1, |
|
140 | + 'method' => 1, |
|
141 | + 'min' => 1, |
|
142 | + 'multiple' => 1, |
|
143 | + 'muted' => 1, |
|
144 | + 'name' => 1, |
|
145 | + 'novalidate' => 1, |
|
146 | + 'onabort' => 1, |
|
147 | + 'onafterprint' => 1, |
|
148 | + 'onbeforeprint' => 1, |
|
149 | + 'onbeforeunload' => 1, |
|
150 | + 'onblur' => 1, |
|
151 | + 'oncanplay' => 1, |
|
152 | + 'oncanplaythrough' => 1, |
|
153 | + 'onchange' => 1, |
|
154 | + 'onclick' => 1, |
|
155 | + 'oncontextmenu' => 1, |
|
156 | + 'oncopy' => 1, |
|
157 | + 'oncuechange' => 1, |
|
158 | + 'oncut' => 1, |
|
159 | + 'ondblclick' => 1, |
|
160 | + 'ondrag' => 1, |
|
161 | + 'ondragend' => 1, |
|
162 | + 'ondragenter' => 1, |
|
163 | + 'ondragleave' => 1, |
|
164 | + 'ondragover' => 1, |
|
165 | + 'ondragstart' => 1, |
|
166 | + 'ondrop' => 1, |
|
167 | + 'ondurationchange' => 1, |
|
168 | + 'onemptied' => 1, |
|
169 | + 'onended' => 1, |
|
170 | + 'onerror' => 1, |
|
171 | + 'onfocus' => 1, |
|
172 | + 'onhashchange' => 1, |
|
173 | + 'oninput' => 1, |
|
174 | + 'oninvalid' => 1, |
|
175 | + 'onkeydown' => 1, |
|
176 | + 'onkeypress' => 1, |
|
177 | + 'onkeyup' => 1, |
|
178 | + 'onload' => 1, |
|
179 | + 'onloadeddata' => 1, |
|
180 | + 'onloadedmetadata' => 1, |
|
181 | + 'onloadstart' => 1, |
|
182 | + 'onmousedown' => 1, |
|
183 | + 'onmousemove' => 1, |
|
184 | + 'onmouseout' => 1, |
|
185 | + 'onmouseover' => 1, |
|
186 | + 'onmouseup' => 1, |
|
187 | + 'onmousewheel' => 1, |
|
188 | + 'onoffline' => 1, |
|
189 | + 'ononline' => 1, |
|
190 | + 'onpageshow' => 1, |
|
191 | + 'onpaste' => 1, |
|
192 | + 'onpause' => 1, |
|
193 | + 'onplay' => 1, |
|
194 | + 'onplaying' => 1, |
|
195 | + 'onprogress' => 1, |
|
196 | + 'onratechange' => 1, |
|
197 | + 'onreset' => 1, |
|
198 | + 'onresize' => 1, |
|
199 | + 'onscroll' => 1, |
|
200 | + 'onsearch' => 1, |
|
201 | + 'onseeked' => 1, |
|
202 | + 'onseeking' => 1, |
|
203 | + 'onselect' => 1, |
|
204 | + 'onstalled' => 1, |
|
205 | + 'onsubmit' => 1, |
|
206 | + 'onsuspend' => 1, |
|
207 | + 'ontimeupdate' => 1, |
|
208 | + 'ontoggle' => 1, |
|
209 | + 'onunload' => 1, |
|
210 | + 'onvolumechange' => 1, |
|
211 | + 'onwaiting' => 1, |
|
212 | + 'onwheel' => 1, |
|
213 | + 'open' => 1, |
|
214 | + 'optimum' => 1, |
|
215 | + 'pattern' => 1, |
|
216 | + 'placeholder' => 1, |
|
217 | + 'poster' => 1, |
|
218 | + 'preload' => 1, |
|
219 | + 'readonly' => 1, |
|
220 | + 'rel' => 1, |
|
221 | + 'required' => 1, |
|
222 | + 'reversed' => 1, |
|
223 | + 'rows' => 1, |
|
224 | + 'rowspan' => 1, |
|
225 | + 'sandbox' => 1, |
|
226 | + 'scope' => 1, |
|
227 | + 'selected' => 1, |
|
228 | + 'shape' => 1, |
|
229 | + 'size' => 1, |
|
230 | + 'sizes' => 1, |
|
231 | + 'span' => 1, |
|
232 | + 'spellcheck' => 1, |
|
233 | + 'src' => 1, |
|
234 | + 'srcdoc' => 1, |
|
235 | + 'srclang' => 1, |
|
236 | + 'source' => 1, |
|
237 | + 'start' => 1, |
|
238 | + 'step' => 1, |
|
239 | + 'style' => 1, |
|
240 | + 'tabindex' => 1, |
|
241 | + 'target' => 1, |
|
242 | + 'title' => 1, |
|
243 | + 'translate' => 1, |
|
244 | + 'type' => 1, |
|
245 | + 'usemap' => 1, |
|
246 | + 'value' => 1, |
|
247 | + 'width' => 1, |
|
248 | + 'wrap' => 1, |
|
249 | 249 | ); |
250 | 250 | protected static $special_tags=array('<doctypetag>'=>'<!doctype>','<htmltag>'=>'<html>','<headtag>'=>'<head>','<htmltag>'=>'<html>','<bodytag>'=>'<body>'); |
251 | 251 | protected static $tags=array( |
252 | - '<php>'=> 1, |
|
253 | - '<!-- -->' => 1, |
|
254 | - '<doctypetag>' => 1, |
|
255 | - '<a>' => 1, |
|
256 | - '<abbr>' => 1, |
|
257 | - '<acronym>' => 1, |
|
258 | - '<address>' => 1, |
|
259 | - '<applet>' => 1, |
|
260 | - '<embed>' => 1, |
|
261 | - '<object>' => 1, |
|
262 | - '<area>' => 1, |
|
263 | - '<article>' => 1, |
|
264 | - '<aside>' => 1, |
|
265 | - '<audio>' => 1, |
|
266 | - '<b>' => 1, |
|
267 | - '<base>' => 1, |
|
268 | - '<basefont>' => 1, |
|
269 | - '<bdi>' => 1, |
|
270 | - '<bdo>' => 1, |
|
271 | - '<big>' => 1, |
|
272 | - '<blockquote>' => 1, |
|
273 | - '<bodytag>' => 1, |
|
274 | - '<br>' => 1, |
|
275 | - '<button>' => 1, |
|
276 | - '<canvas>' => 1, |
|
277 | - '<caption>' => 1, |
|
278 | - '<center>' => 1, |
|
279 | - '<cite>' => 1, |
|
280 | - '<code>' => 1, |
|
281 | - '<col>' => 1, |
|
282 | - '<colgroup>' => 1, |
|
283 | - '<data>' => 1, |
|
284 | - '<datalist>' => 1, |
|
285 | - '<dd>' => 1, |
|
286 | - '<del>' => 1, |
|
287 | - '<details>' => 1, |
|
288 | - '<dfn>' => 1, |
|
289 | - '<dialog>' => 1, |
|
290 | - '<dir>' => 1, |
|
291 | - '<ul>' => 1, |
|
292 | - '<div>' => 1, |
|
293 | - '<dl>' => 1, |
|
294 | - '<dt>' => 1, |
|
295 | - '<em>' => 1, |
|
296 | - '<fieldset>' => 1, |
|
297 | - '<figcaption>' => 1, |
|
298 | - '<figure>' => 1, |
|
299 | - '<font>' => 1, |
|
300 | - '<footer>' => 1, |
|
301 | - '<form>' => 1, |
|
302 | - '<frame>' => 1, |
|
303 | - '<frameset>' => 1, |
|
304 | - '<h1>' => 1, |
|
305 | - '<h2>' => 1, |
|
306 | - '<h3>' => 1, |
|
307 | - '<h5>' => 1, |
|
308 | - '<h6>' => 1, |
|
309 | - '<hn>' => 1, |
|
310 | - '<headtag>' => 1, |
|
311 | - '<header>' => 1, |
|
312 | - '<hr>' => 1, |
|
313 | - '<htmltag>' => 1, |
|
314 | - '<i>' => 1, |
|
315 | - '<iframe>' => 1, |
|
316 | - '<img>' => 1, |
|
317 | - '<input>' => 1, |
|
318 | - '<ins>' => 1, |
|
319 | - '<kbd>' => 1, |
|
320 | - '<label>' => 1, |
|
321 | - '<legend>' => 1, |
|
322 | - '<li>' => 1, |
|
323 | - '<link>' => 1, |
|
324 | - '<main>' => 1, |
|
325 | - '<map>' => 1, |
|
326 | - '<mark>' => 1, |
|
327 | - '<meta>' => 1, |
|
328 | - '<meter>' => 1, |
|
329 | - '<nav>' => 1, |
|
330 | - '<noframes>' => 1, |
|
331 | - '<noscript>' => 1, |
|
332 | - '<ol>' => 1, |
|
333 | - '<optgroup>' => 1, |
|
334 | - '<option>' => 1, |
|
335 | - '<output>' => 1, |
|
336 | - '<p>' => 1, |
|
337 | - '<param>' => 1, |
|
338 | - '<picture>' => 1, |
|
339 | - '<pre>' => 1, |
|
340 | - '<progress>' => 1, |
|
341 | - '<q>' => 1, |
|
342 | - '<rp>' => 1, |
|
343 | - '<rt>' => 1, |
|
344 | - '<ruby>' => 1, |
|
345 | - '<s>' => 1, |
|
346 | - '<samp>' => 1, |
|
347 | - '<script>' => 1, |
|
348 | - '<section>' => 1, |
|
349 | - '<select>' => 1, |
|
350 | - '<small>' => 1, |
|
351 | - '<source>' => 1, |
|
352 | - '<span>' => 1, |
|
353 | - '<strike>' => 1, |
|
354 | - '<strong>' => 1, |
|
355 | - '<style>' => 1, |
|
356 | - '<sub>' => 1, |
|
357 | - '<summary>' => 1, |
|
358 | - '<sup>' => 1, |
|
359 | - '<svg>' => 1, |
|
360 | - '<table>' => 1, |
|
361 | - '<tbody>' => 1, |
|
362 | - '<td>' => 1, |
|
363 | - '<template>' => 1, |
|
364 | - '<textarea>' => 1, |
|
365 | - '<tfoot>' => 1, |
|
366 | - '<th>' => 1, |
|
367 | - '<thead>' => 1, |
|
368 | - '<time>' => 1, |
|
369 | - '<title>' => 1, |
|
370 | - '<tr>' => 1, |
|
371 | - '<track>' => 1, |
|
372 | - '<tt>' => 1, |
|
373 | - '<u>' => 1, |
|
374 | - '<var>' => 1, |
|
375 | - '<video>' => 1, |
|
376 | - '<wbr>' => 1, |
|
252 | + '<php>'=> 1, |
|
253 | + '<!-- -->' => 1, |
|
254 | + '<doctypetag>' => 1, |
|
255 | + '<a>' => 1, |
|
256 | + '<abbr>' => 1, |
|
257 | + '<acronym>' => 1, |
|
258 | + '<address>' => 1, |
|
259 | + '<applet>' => 1, |
|
260 | + '<embed>' => 1, |
|
261 | + '<object>' => 1, |
|
262 | + '<area>' => 1, |
|
263 | + '<article>' => 1, |
|
264 | + '<aside>' => 1, |
|
265 | + '<audio>' => 1, |
|
266 | + '<b>' => 1, |
|
267 | + '<base>' => 1, |
|
268 | + '<basefont>' => 1, |
|
269 | + '<bdi>' => 1, |
|
270 | + '<bdo>' => 1, |
|
271 | + '<big>' => 1, |
|
272 | + '<blockquote>' => 1, |
|
273 | + '<bodytag>' => 1, |
|
274 | + '<br>' => 1, |
|
275 | + '<button>' => 1, |
|
276 | + '<canvas>' => 1, |
|
277 | + '<caption>' => 1, |
|
278 | + '<center>' => 1, |
|
279 | + '<cite>' => 1, |
|
280 | + '<code>' => 1, |
|
281 | + '<col>' => 1, |
|
282 | + '<colgroup>' => 1, |
|
283 | + '<data>' => 1, |
|
284 | + '<datalist>' => 1, |
|
285 | + '<dd>' => 1, |
|
286 | + '<del>' => 1, |
|
287 | + '<details>' => 1, |
|
288 | + '<dfn>' => 1, |
|
289 | + '<dialog>' => 1, |
|
290 | + '<dir>' => 1, |
|
291 | + '<ul>' => 1, |
|
292 | + '<div>' => 1, |
|
293 | + '<dl>' => 1, |
|
294 | + '<dt>' => 1, |
|
295 | + '<em>' => 1, |
|
296 | + '<fieldset>' => 1, |
|
297 | + '<figcaption>' => 1, |
|
298 | + '<figure>' => 1, |
|
299 | + '<font>' => 1, |
|
300 | + '<footer>' => 1, |
|
301 | + '<form>' => 1, |
|
302 | + '<frame>' => 1, |
|
303 | + '<frameset>' => 1, |
|
304 | + '<h1>' => 1, |
|
305 | + '<h2>' => 1, |
|
306 | + '<h3>' => 1, |
|
307 | + '<h5>' => 1, |
|
308 | + '<h6>' => 1, |
|
309 | + '<hn>' => 1, |
|
310 | + '<headtag>' => 1, |
|
311 | + '<header>' => 1, |
|
312 | + '<hr>' => 1, |
|
313 | + '<htmltag>' => 1, |
|
314 | + '<i>' => 1, |
|
315 | + '<iframe>' => 1, |
|
316 | + '<img>' => 1, |
|
317 | + '<input>' => 1, |
|
318 | + '<ins>' => 1, |
|
319 | + '<kbd>' => 1, |
|
320 | + '<label>' => 1, |
|
321 | + '<legend>' => 1, |
|
322 | + '<li>' => 1, |
|
323 | + '<link>' => 1, |
|
324 | + '<main>' => 1, |
|
325 | + '<map>' => 1, |
|
326 | + '<mark>' => 1, |
|
327 | + '<meta>' => 1, |
|
328 | + '<meter>' => 1, |
|
329 | + '<nav>' => 1, |
|
330 | + '<noframes>' => 1, |
|
331 | + '<noscript>' => 1, |
|
332 | + '<ol>' => 1, |
|
333 | + '<optgroup>' => 1, |
|
334 | + '<option>' => 1, |
|
335 | + '<output>' => 1, |
|
336 | + '<p>' => 1, |
|
337 | + '<param>' => 1, |
|
338 | + '<picture>' => 1, |
|
339 | + '<pre>' => 1, |
|
340 | + '<progress>' => 1, |
|
341 | + '<q>' => 1, |
|
342 | + '<rp>' => 1, |
|
343 | + '<rt>' => 1, |
|
344 | + '<ruby>' => 1, |
|
345 | + '<s>' => 1, |
|
346 | + '<samp>' => 1, |
|
347 | + '<script>' => 1, |
|
348 | + '<section>' => 1, |
|
349 | + '<select>' => 1, |
|
350 | + '<small>' => 1, |
|
351 | + '<source>' => 1, |
|
352 | + '<span>' => 1, |
|
353 | + '<strike>' => 1, |
|
354 | + '<strong>' => 1, |
|
355 | + '<style>' => 1, |
|
356 | + '<sub>' => 1, |
|
357 | + '<summary>' => 1, |
|
358 | + '<sup>' => 1, |
|
359 | + '<svg>' => 1, |
|
360 | + '<table>' => 1, |
|
361 | + '<tbody>' => 1, |
|
362 | + '<td>' => 1, |
|
363 | + '<template>' => 1, |
|
364 | + '<textarea>' => 1, |
|
365 | + '<tfoot>' => 1, |
|
366 | + '<th>' => 1, |
|
367 | + '<thead>' => 1, |
|
368 | + '<time>' => 1, |
|
369 | + '<title>' => 1, |
|
370 | + '<tr>' => 1, |
|
371 | + '<track>' => 1, |
|
372 | + '<tt>' => 1, |
|
373 | + '<u>' => 1, |
|
374 | + '<var>' => 1, |
|
375 | + '<video>' => 1, |
|
376 | + '<wbr>' => 1, |
|
377 | 377 | ); |
378 | 378 | |
379 | 379 | protected function loadHTML($html) |
@@ -247,7 +247,7 @@ discard block |
||
247 | 247 | 'width' => 1, |
248 | 248 | 'wrap' => 1, |
249 | 249 | ); |
250 | - protected static $special_tags=array('<doctypetag>'=>'<!doctype>','<htmltag>'=>'<html>','<headtag>'=>'<head>','<htmltag>'=>'<html>','<bodytag>'=>'<body>'); |
|
250 | + protected static $special_tags=array('<doctypetag>'=>'<!doctype>', '<htmltag>'=>'<html>', '<headtag>'=>'<head>', '<htmltag>'=>'<html>', '<bodytag>'=>'<body>'); |
|
251 | 251 | protected static $tags=array( |
252 | 252 | '<php>'=> 1, |
253 | 253 | '<!-- -->' => 1, |
@@ -381,7 +381,7 @@ discard block |
||
381 | 381 | if (!strlen($html)) { |
382 | 382 | throw new \InvalidArgumentException("Empty string given"); |
383 | 383 | } |
384 | - $xml = new \DOMDocument(); |
|
384 | + $xml=new \DOMDocument(); |
|
385 | 385 | //Suppress warnings: proper error handling is beyond scope of example |
386 | 386 | libxml_use_internal_errors(true); |
387 | 387 | |
@@ -450,9 +450,8 @@ discard block |
||
450 | 450 | { |
451 | 451 | $result=$domDoc->saveHTML(); |
452 | 452 | self::handleMainHtmlTags($result, $allowed_tags); |
453 | - return substr(($is_php&&isset($allowed_tags['<php>']))? |
|
454 | - str_replace(array('<php>','</php>'), array('<?php ','?>'), $result): |
|
455 | - $result, stripos($result, '<div>')+5, -7); |
|
453 | + return substr(($is_php&&isset($allowed_tags['<php>'])) ? |
|
454 | + str_replace(array('<php>', '</php>'), array('<?php ', '?>'), $result) : $result, stripos($result, '<div>')+5, -7); |
|
456 | 455 | } |
457 | 456 | |
458 | 457 | protected static function handleMainHtmlTags(&$result, &$allowed_tags) |
@@ -27,7 +27,7 @@ |
||
27 | 27 | ).'</doctypetag></div>'; |
28 | 28 | $preprocessed=token_get_all($html); |
29 | 29 | |
30 | - $HTML=array_filter($preprocessed, function ($v) { |
|
30 | + $HTML=array_filter($preprocessed, function($v) { |
|
31 | 31 | return is_array($v)&&$v[0]===T_INLINE_HTML; |
32 | 32 | }); |
33 | 33 | $PHP=array_diff_key($preprocessed, $HTML); |