Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Comments

Prevent attempts at nesting character sets in regex filter#389

Open
JoshuaS3 wants to merge 2 commits intostrinking:master from
JoshuaS3:filter-regexp2
Open

Prevent attempts at nesting character sets in regex filter #389
JoshuaS3 wants to merge 2 commits intostrinking:master from
JoshuaS3:filter-regexp2

Conversation

@JoshuaS3
Copy link
Contributor

@JoshuaS3 JoshuaS3 commented Mar 17, 2023

Not sure how I didn't catch this when testing the initial regex feature a couple years ago. Basically, nesting character sets is impossible in Python's regex, which is what my filter code tried to do because it wasn't checking for IN tokens, so those confusable glyphs would be discarded by the regex compiler (thankfully it doesn't outright throw an error). This PR adds that check and performs confusable insertion in place for those sets. Also cleans up some of the code in that area.

Example of the issue:
h[ea]lp would effectively be converted into this, which is invalid regex:

[hhhhhhhhhhhhhhhһհᏂ]**[**[e℮eeeeeeeeeeeeeeeꬲеҽ][a⍺aaaaaaaaaaaaaaɑααααααа]**]**[l11111IIIIIIIIIIIIIIIIƖllllllllllllllllǀΙΙΙΙΙΙⲒІӀⵏᛁꓲ𖼨𐊊𐌉][p⍴ppppppppppppppρρρρρρρρρρρρⲣр]

instead of this, which is valid and desired:

[hhhhhhhhhhhhhhhһհᏂ]**[**e℮eeeeeeeeeeeeeeeꬲеҽa⍺aaaaaaaaaaaaaaɑααααααа**]**[l11111IIIIIIIIIIIIIIIIƖllllllllllllllllǀΙΙΙΙΙΙⲒІӀⵏᛁꓲ𖼨𐊊𐌉][p⍴ppppppppppppppρρρρρρρρρρρρⲣр]

(** only added for emphasis)

Not sure how I didn't catch this when testing a couple years ago.
Basically, nesting character sets is impossible in Python's regex, which
is what my filter code tried to do because it wasn't checking for IN
tokens. This adds that check and performs confusable insertion in place
for those sets. Also cleans up some of the code in that area.
Also missed this. "a-z" in [a-z] is tokenized as (RANGE, (97, 122)).
This commit adds support for those tokens.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@Ma-wa-re Ma-wa-re Awaiting requested review from Ma-wa-re

At least 1 approving review is required to merge this pull request.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

1 participant

AltStyle によって変換されたページ (->オリジナル) /