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

vimoption2python no longer creates ambiguous regex syntax #939

Merged
merged 2 commits into from Feb 17, 2019

Conversation

Hamled
Copy link
Contributor

@Hamled Hamled commented Feb 16, 2019

Python 3.7+ makes it so that a FutureWarning notice is printed whenever a regular expression is compiled that contains a sequence which might become ambiguous if nested set operations are added.

There are some cases where Deoplete's vimoption2python function could produce such a sequence when generating a Python regex for the plugin code to use. In particular, I found this happened from the built-in scheme filetype.

The iskeyword setting for Scheme is 33,35-39,42-43,45-58,60-90,94,95,97-122,126 which is converted by vimoptions2python into [\w!#-'*-+--:<-Z^_a-z~] (the issue is the 4th pattern which gets converted into --:).

The change in this PR inserts an additional check before adding a pattern to the list, to determine if it's a character range and either the beginning or end character in the range is -. If that is the case, we escape the literal hyphen (e.g. if the pattern was !-- we would escape it to !-\- instead of !\--). I don't believe we will encounter the other ambiguous regex syntax cases in this code path.

All of that being said, I'm very unfamiliar with Vimscript so I would encourage a thorough review and consideration of any possible edge cases I've missed!

@codecov-io
Copy link

Codecov Report

Merging #939 into master will not change coverage.
The diff coverage is n/a.

@@           Coverage Diff           @@
##           master     #939   +/-   ##
=======================================
  Coverage   47.88%   47.88%           
=======================================
  Files          18       18           
  Lines         875      875           
=======================================
  Hits          419      419           
  Misses        456      456

@Shougo Shougo merged commit ab62032 into Shougo:master Feb 17, 2019
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

Successfully merging this pull request may close these issues.

None yet

3 participants