@@ -124,14 +124,6 @@ class BaseParser
124
124
}
125
125
126
126
module Private
127
- # Terminal requires two or more letters.
128
- INSTRUCTION_TERM = "?>"
129
- COMMENT_TERM = "-->"
130
- CDATA_TERM = "]]>"
131
- DOCTYPE_TERM = "]>"
132
- # Read to the end of DOCTYPE because there is no proper ENTITY termination
133
- ENTITY_TERM = DOCTYPE_TERM
134
-
135
127
INSTRUCTION_END = /#{ NAME } (\s +.*?)?\? >/um
136
128
TAG_PATTERN = /((?>#{ QNAME_STR } ))\s */um
137
129
CLOSE_PATTERN = /(#{ QNAME_STR } )\s *>/um
@@ -253,7 +245,7 @@ def pull_event
253
245
return process_instruction ( start_position )
254
246
elsif @source . match ( "<!" , true )
255
247
if @source . match ( "--" , true )
256
- md = @source . match ( /(.*?)-->/um , true , term : Private :: COMMENT_TERM )
248
+ md = @source . match ( /(.*?)-->/um , true )
257
249
if md . nil?
258
250
raise REXML ::ParseException . new ( "Unclosed comment" , @source )
259
251
end
@@ -320,7 +312,7 @@ def pull_event
320
312
raise REXML ::ParseException . new ( "Bad ELEMENT declaration!" , @source ) if md . nil?
321
313
return [ :elementdecl , "<!ELEMENT" + md [ 1 ] ]
322
314
elsif @source . match ( "ENTITY" , true )
323
- match_data = @source . match ( Private ::ENTITYDECL_PATTERN , true , term : Private :: ENTITY_TERM )
315
+ match_data = @source . match ( Private ::ENTITYDECL_PATTERN , true )
324
316
unless match_data
325
317
raise REXML ::ParseException . new ( "Malformed entity declaration" , @source )
326
318
end
@@ -389,14 +381,14 @@ def pull_event
389
381
raise REXML ::ParseException . new ( message , @source )
390
382
end
391
383
return [ :notationdecl , name , *id ]
392
- elsif md = @source . match ( /--(.*?)-->/um , true , term : Private :: COMMENT_TERM )
384
+ elsif md = @source . match ( /--(.*?)-->/um , true )
393
385
case md [ 1 ]
394
386
when /--/ , /-\z /
395
387
raise REXML ::ParseException . new ( "Malformed comment" , @source )
396
388
end
397
389
return [ :comment , md [ 1 ] ] if md
398
390
end
399
- elsif match = @source . match ( /(%.*?;)\s */um , true , term : Private :: DOCTYPE_TERM )
391
+ elsif match = @source . match ( /(%.*?;)\s */um , true )
400
392
return [ :externalentity , match [ 1 ] ]
401
393
elsif @source . match ( /\] \s *>/um , true )
402
394
@document_status = :after_doctype
@@ -436,15 +428,15 @@ def pull_event
436
428
#STDERR.puts "SOURCE BUFFER = #{source.buffer}, #{source.buffer.size}"
437
429
raise REXML ::ParseException . new ( "Malformed node" , @source ) unless md
438
430
if md [ 0 ] [ 0 ] == ?-
439
- md = @source . match ( /--(.*?)-->/um , true , term : Private :: COMMENT_TERM )
431
+ md = @source . match ( /--(.*?)-->/um , true )
440
432
441
433
if md . nil? || /--|-\z / . match? ( md [ 1 ] )
442
434
raise REXML ::ParseException . new ( "Malformed comment" , @source )
443
435
end
444
436
445
437
return [ :comment , md [ 1 ] ]
446
438
else
447
- md = @source . match ( /\[ CDATA\[ (.*?)\] \] >/um , true , term : Private :: CDATA_TERM )
439
+ md = @source . match ( /\[ CDATA\[ (.*?)\] \] >/um , true )
448
440
return [ :cdata , md [ 1 ] ] if md
449
441
end
450
442
raise REXML ::ParseException . new ( "Declarations can only occur " +
@@ -673,7 +665,7 @@ def parse_id_invalid_details(accept_external_id:,
673
665
end
674
666
675
667
def process_instruction ( start_position )
676
- match_data = @source . match ( Private ::INSTRUCTION_END , true , term : Private :: INSTRUCTION_TERM )
668
+ match_data = @source . match ( Private ::INSTRUCTION_END , true )
677
669
unless match_data
678
670
message = "Invalid processing instruction node"
679
671
@source . position = start_position
0 commit comments