File tree Expand file tree Collapse file tree 3 files changed +20
-7
lines changed Expand file tree Collapse file tree 3 files changed +20
-7
lines changed Original file line number Diff line number Diff line change @@ -104,7 +104,7 @@ public function position()
104
104
*/
105
105
public function peek ()
106
106
{
107
- if (($ this ->char + 1 ) <= $ this ->EOF ) {
107
+ if (($ this ->char + 1 ) < $ this ->EOF ) {
108
108
return $ this ->data [$ this ->char + 1 ];
109
109
}
110
110
Original file line number Diff line number Diff line change @@ -712,18 +712,24 @@ protected function isCommentEnd()
712
712
return true ;
713
713
}
714
714
715
- // If it doesn't start with - , not the end.
716
- if ('- ' != $ tok ) {
715
+ // If next two tokens are not '--' , not the end.
716
+ if ('- ' != $ tok || ' - ' != $ this -> scanner -> peek () ) {
717
717
return false ;
718
718
}
719
719
720
- // Advance one, and test for '->'
721
- if ('- ' == $ this ->scanner ->next () && '> ' == $ this ->scanner ->peek ()) {
720
+ $ this ->scanner ->consume (2 ); // Consume '-' and one of '!' or '>'
721
+
722
+ // Test for '>'
723
+ if ('> ' == $ this ->scanner ->current ()) {
724
+ return true ;
725
+ }
726
+ // Test for '!>'
727
+ if ('! ' == $ this ->scanner ->current () && '> ' == $ this ->scanner ->peek ()) {
722
728
$ this ->scanner ->consume (); // Consume the last '>'
723
729
return true ;
724
730
}
725
- // Unread '-';
726
- $ this ->scanner ->unconsume (1 );
731
+ // Unread '-' and one of '!' or '>' ;
732
+ $ this ->scanner ->unconsume (2 );
727
733
728
734
return false ;
729
735
}
Original file line number Diff line number Diff line change @@ -197,11 +197,17 @@ public function testComment()
197
197
{
198
198
$ good = array (
199
199
'<!--easy--> ' => 'easy ' ,
200
+ '<!--easy--!> ' => 'easy ' ,
200
201
'<!-- 1 > 0 --> ' => ' 1 > 0 ' ,
202
+ '<!-- 1 > 0 --!> ' => ' 1 > 0 ' ,
201
203
'<!-- --$i --> ' => ' --$i ' ,
204
+ '<!-- --$i --!> ' => ' --$i ' ,
202
205
'<!----$i--> ' => '--$i ' ,
206
+ '<!----$i--!> ' => '--$i ' ,
203
207
"<!-- \nHello World. \na--> " => "\nHello World. \na " ,
208
+ "<!-- \nHello World. \na--!> " => "\nHello World. \na " ,
204
209
'<!-- <!-- --> ' => ' <!-- ' ,
210
+ '<!-- <!-- --!> ' => ' <!-- ' ,
205
211
);
206
212
foreach ($ good as $ test => $ expected ) {
207
213
$ events = $ this ->parse ($ test );
@@ -213,6 +219,7 @@ public function testComment()
213
219
'<!--Hello ' => 'Hello ' ,
214
220
"<!-- \0Hello " => UTF8Utils::FFFD . 'Hello ' ,
215
221
'<!-- ' => '' ,
222
+ '<!--<!-- ' => '<!-- ' ,
216
223
);
217
224
foreach ($ fail as $ test => $ expected ) {
218
225
$ events = $ this ->parse ($ test );
You can’t perform that action at this time.
0 commit comments