File tree 2 files changed +15
-0
lines changed
2 files changed +15
-0
lines changed Original file line number Diff line number Diff line change @@ -140,6 +140,10 @@ public function setInput($input)
140
140
*/
141
141
public function showPosition ()
142
142
{
143
+ if ($ this ->yylineno === 0 && $ this ->offset === 1 && $ this ->match !== '{ ' ) {
Has conversations. Original line has conversations.
144
+ return $ this ->match .'... ' . "\n^ " ;
145
+ }
146
+
143
147
$ pre = str_replace ("\n" , '' , $ this ->getPastInput ());
144
148
$ c = str_repeat ('- ' , max (0 , \strlen ($ pre ) - 1 )); // new Array(pre.length + 1).join("-");
145
149
Original file line number Diff line number Diff line change @@ -177,6 +177,17 @@ public function testErrorAtBeginning()
177
177
}
178
178
}
179
179
180
+ public function testAvoidLeakingInfoForInvalidFiles ()
181
+ {
182
+ $ parser = new JsonParser ();
183
+ try {
184
+ $ parser ->parse ('ABCD ' );
185
+ $ this ->fail ('Empty string should be invalid ' );
186
+ } catch (ParsingException $ e ) {
187
+ $ this ->assertContains ("Parse error on line 1: \nA... \n^ " , $ e ->getMessage ());
188
+ }
189
+ }
190
+
180
191
public function testParsesMultiInARow ()
181
192
{
182
193
$ parser = new JsonParser ();
You can’t perform that action at this time.