Skip to content

Conversation

naitoh
Copy link
Contributor

@naitoh naitoh commented Aug 28, 2025

Why?

Avoid causing an error when @source.eof? is called after IOSource#read_until is invoked in subsequent processing.

/.gems/gems/rexml-3.4.2/lib/rexml/parsers/baseparser.rb:524:in 'REXML::Parsers::BaseParser#pull_event': #<NoMethodError: undefined method 'eof?' for nil> (REXML::ParseException)
.gems/gems/rexml-3.4.2/lib/rexml/source.rb:275:in 'REXML::IOSource#read_until'

rexml/lib/rexml/source.rb

Lines 266 to 276 in 185bdc7

def read_until(term)
pattern = Private::PRE_DEFINED_TERM_PATTERNS[term] || /#{Regexp.escape(term)}/
term = @encoded_terms[term] ||= encode(term)
until str = @scanner.scan_until(pattern)
break if @source.nil?
break if @source.eof?
@scanner << readline(term)
end
if str
read if @scanner.eos? and !@source.eof?
str

See: #287

…OSource#read`.

## Why?
Avoid causing an error when `@source.eof?` is called after `IOSource#read_until` is invoked in subsequent processing.

> /.gems/gems/rexml-3.4.2/lib/rexml/parsers/baseparser.rb:524:in 'REXML::Parsers::BaseParser#pull_event': #<NoMethodError: undefined method 'eof?' for nil> (REXML::ParseException)
> .gems/gems/rexml-3.4.2/lib/rexml/source.rb:275:in 'REXML::IOSource#read_until'

See: https://github.com/ruby/rexml/blob/185bdc737da406ba4f9564726849ad3477858eb2/lib/rexml/source.rb#L266-L276
@naitoh naitoh marked this pull request as draft August 28, 2025 13:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant