Skip to content
This repository was archived by the owner on Dec 15, 2022. It is now read-only.

Fix parsing of raw strings containing unclosed parentheses and brackets #37

Merged
merged 2 commits into from
Nov 7, 2014

Conversation

aroben
Copy link
Contributor

@aroben aroben commented Nov 6, 2014

Strings like r'[' and r'(' were causing the rest of the document to be parsed as if it were inside the regex. Now we terminate the regex at the closing quote in all cases.

This is a backport of textmate/python.tmbundle@2567262

/cc @vmg

Strings like r'[' and r'(' were causing the rest of the document to be
parsed as if it were inside the regex. Now we terminate the regex at the
closing quote in all cases.

This is a backport of
textmate/python.tmbundle@2567262
'3':
'name': 'invalid.illegal.unclosed-string.python'
'patterns': [
'include': '#constant_placeholder'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will combine to a single object with duplicate include keys when compiled to JavaSript:

'patterns': [
    {
      'include': '#constant_placeholder',
      'include': '#escaped_unicode_char',
      'include': '#escaped_char',
      'include': '#regular_expressions'
    }
  ]

You probably want it to be:

'patterns': [
  {'include': '#constant_placeholder'}
  {'include': '#escaped_unicode_char'}
  {'include': '#escaped_char'}
  {'include': '#regular_expressions'}
]

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right. I guess I should make the tests sensitive to that bug.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed and tested.

My CSON formatting was bad, which caused only the regular expression
grammar to get parsed inside of raw strings.
@aroben aroben force-pushed the fix-unclosed-regexes branch from a5d798c to c2120ec Compare November 7, 2014 14:32
@aroben
Copy link
Contributor Author

aroben commented Nov 7, 2014

@kevinsawicki This is ready for review again.

@aroben
Copy link
Contributor Author

aroben commented Nov 7, 2014

The diff is a little hard to read (though much less so than the original XML diff!). The summary is that these rules have been changed from begin/end to using match. This seems to have the desired effect of not letting the embedded regex grammar extend outside of the string.

@kevinsawicki
Copy link
Contributor

🚢

kevinsawicki added a commit that referenced this pull request Nov 7, 2014
Fix parsing of raw strings containing unclosed parentheses and brackets
@kevinsawicki kevinsawicki merged commit 10b3526 into atom:master Nov 7, 2014
@kevinsawicki
Copy link
Contributor

Published as 0.23

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants