File tree 2 files changed +10
-2
lines changed 2 files changed +10
-2
lines changed Original file line number Diff line number Diff line change @@ -305,6 +305,7 @@ def test_parse_exceptions(self):
305
305
# invalid syntax
306
306
'"asd" "123"\n "zxc" "333"\n "' ,
307
307
'asd 123\n zxc 333\n "' ,
308
+ '"asd\n \n \n \n \n zxc' ,
308
309
309
310
# one too many closing parenthasis
310
311
'"asd"\n {\n "zxc" "123"\n }\n }\n }\n }\n ' ,
Original file line number Diff line number Diff line change @@ -83,7 +83,11 @@ def parse(fp, mapper=dict):
83
83
match = re_keyvalue .match (line )
84
84
85
85
if not match :
86
- raise SyntaxError ("vdf.parse: invalid syntax (line %d)" % (idx + 1 ))
86
+ try :
87
+ line += next (fp )
88
+ except StopIteration :
89
+ raise SyntaxError ("vdf.parse: unexpected EOF (open key quote?)" )
90
+ continue
87
91
88
92
key = match .group ('key' ) if match .group ('qkey' ) is None else match .group ('qkey' )
89
93
val = match .group ('val' ) if match .group ('qval' ) is None else match .group ('qval' )
@@ -100,7 +104,10 @@ def parse(fp, mapper=dict):
100
104
# if the value is line consume one more line and try to match again,
101
105
# until we get the KeyValue pair
102
106
if match .group ('vq_end' ) is None and match .group ('qval' ) is not None :
103
- line += next (fp )
107
+ try :
108
+ line += next (fp )
109
+ except StopIteration :
110
+ raise SyntaxError ("vdf.parse: unexpected EOF (open value quote?)" )
104
111
continue
105
112
106
113
stack [- 1 ][key ] = val
You can’t perform that action at this time.
0 commit comments