File tree Expand file tree Collapse file tree 2 files changed +14
-4
lines changed
Expand file tree Collapse file tree 2 files changed +14
-4
lines changed Original file line number Diff line number Diff line change @@ -223,10 +223,20 @@ public function getNumeric()
223223 * Consume whitespace.
224224 *
225225 * Whitespace in HTML5 is: formfeed, tab, newline, space.
226+ *
227+ * @return int The length of the matched whitespaces
226228 */
227229 public function whitespace ()
228230 {
229- return $ this ->doCharsWhile ("\n\t\f " );
231+ if ($ this ->char >= $ this ->EOF ) {
232+ return false ;
233+ }
234+
235+ $ len = strspn ($ this ->data , "\n\t\f " , $ this ->char );
236+
237+ $ this ->char += $ len ;
238+
239+ return $ len ;
230240 }
231241
232242 /**
Original file line number Diff line number Diff line change @@ -279,7 +279,7 @@ protected function rcdata($tok)
279279 }
280280 $ len = strlen ($ sequence );
281281 $ this ->scanner ->consume ($ len );
282- $ len += strlen ( $ this ->scanner ->whitespace () );
282+ $ len += $ this ->scanner ->whitespace ();
283283 if ($ this ->scanner ->current () !== '> ' ) {
284284 $ this ->parseError ("Unclosed RCDATA end tag " );
285285 }
@@ -779,7 +779,7 @@ protected function doctype()
779779 $ this ->scanner ->whitespace ();
780780
781781 $ pub = strtoupper ($ this ->scanner ->getAsciiAlpha ());
782- $ white = strlen ( $ this ->scanner ->whitespace () );
782+ $ white = $ this ->scanner ->whitespace ();
783783
784784 // Get ID, and flag it as pub or system.
785785 if (($ pub == 'PUBLIC ' || $ pub == 'SYSTEM ' ) && $ white > 0 ) {
@@ -909,7 +909,7 @@ protected function processingInstruction()
909909
910910 $ tok = $ this ->scanner ->next ();
911911 $ procName = $ this ->scanner ->getAsciiAlpha ();
912- $ white = strlen ( $ this ->scanner ->whitespace () );
912+ $ white = $ this ->scanner ->whitespace ();
913913
914914 // If not a PI, send to bogusComment.
915915 if (strlen ($ procName ) == 0 || $ white == 0 || $ this ->scanner ->current () == false ) {
You can’t perform that action at this time.
0 commit comments