File tree 3 files changed +24
-1
lines changed
3 files changed +24
-1
lines changed Original file line number Diff line number Diff line change @@ -167,6 +167,7 @@ def initialize( source )
167
167
@entity_expansion_count = 0
168
168
@entity_expansion_limit = Security . entity_expansion_limit
169
169
@entity_expansion_text_limit = Security . entity_expansion_text_limit
170
+ @source . ensure_buffer
170
171
end
171
172
172
173
def add_listener ( listener )
Original file line number Diff line number Diff line change @@ -295,14 +295,19 @@ def current_line
295
295
296
296
private
297
297
def readline ( term = nil )
298
- str = @source . readline ( term || @line_break )
299
298
if @pending_buffer
299
+ begin
300
+ str = @source . readline ( term || @line_break )
301
+ rescue IOError
302
+ end
300
303
if str . nil?
301
304
str = @pending_buffer
302
305
else
303
306
str = @pending_buffer + str
304
307
end
305
308
@pending_buffer = nil
309
+ else
310
+ str = @source . readline ( term || @line_break )
306
311
end
307
312
return nil if str . nil?
308
313
Original file line number Diff line number Diff line change 4
4
module REXMLTests
5
5
class TestParseText < Test ::Unit ::TestCase
6
6
class TestInvalid < self
7
+ def test_text_only
8
+ exception = assert_raise ( REXML ::ParseException ) do
9
+ parser = REXML ::Parsers ::BaseParser . new ( 'a' )
10
+ while parser . has_next?
11
+ parser . pull
12
+ end
13
+ end
14
+
15
+ assert_equal ( <<~DETAIL . chomp , exception . to_s )
16
+ Malformed XML: Content at the start of the document (got 'a')
17
+ Line: 1
18
+ Position: 1
19
+ Last 80 unconsumed characters:
20
+
21
+ DETAIL
22
+ end
23
+
7
24
def test_before_root
8
25
exception = assert_raise ( REXML ::ParseException ) do
9
26
parser = REXML ::Parsers ::BaseParser . new ( 'b<a></a>' )
You can’t perform that action at this time.
0 commit comments