Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

error for bad backslashes gives unrelated error message with the wrong location #54

Closed
joachim-n opened this issue Jan 18, 2019 · 3 comments

Comments

@joachim-n
Copy link

Given the following JSON:

{
  "SA-CORE-2019-002": "../patches/sa-core-2019-002.patch",
  "#3026386-26 - Drush fatal error after upgrading to 8.6.6, 8.5.9, or 7.62: PHP Fatal error: Uncaught TYPO3\PharStreamWrapper\Exception": "https://www.drupal.org/files/issues/2019-01-16/d8-3026386-26.patch"
}

the error is:

test.json: Parse error on line 2:
...-2019-002.patch",  "#3026386-26 - Drush
---------------------^
Invalid string, it appears you forgot to terminate a string, or attempted to write a multiline string which is invalid - It appears you have an extra trailing comma

The error message doesn't seem related, as there is no extra trailing comma.

@Seldaek
Copy link
Owner

Seldaek commented Jan 28, 2019

I can confirm the issue but I am really not sure how to fix this unfortunately.

@stof
Copy link
Contributor

stof commented Apr 30, 2020

the issue here is that the code figuring out this message relies on reading the upcoming input of the lexer to see the content of the broken string. But this upcoming input returns at most 20 chars, and the unescaped backslash is farther than that in the string. So it the parser does not detect the backslash.

@Seldaek
Copy link
Owner

Seldaek commented Apr 30, 2020

Ah thanks @stof that was helpful to figure out the fix. It's not super elegant because in this state the lexer does not have a proper knowledge of the string yet, but I think it's a safe fix.

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

No branches or pull requests

3 participants