Skip to content

Quote regex meta characters in Rewrite #1541

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

Merged
merged 1 commit into from
Mar 29, 2020
Merged

Conversation

LeafHacker
Copy link
Contributor

@LeafHacker LeafHacker commented Mar 28, 2020

Currently there is a half and half situation where the user can't use regex (fully) because * will be replaced with (.*), yet they also can't just enter any old string, because meta chars like . would need escaping.

e.g. currently *.html wouldn't work as intended, and instead *\.html should be used.

Work around this by using regexp's QuoteMeta function to sanitise the input before handling it.

This is a breaking change, since if someone is already working-around the bug by manually escaping stuff, their escapes would be escaped!

Currently there is a half and half situation where the user can't use regex (fully) because * will be replaced with (.*), yet they also can't just enter any old string, because meta chars like . would need escaping.

e.g. currently *.html wouldn't work as intended, and instead *\.html should be used.

Work around this by using regexp's QuoteMeta function to sanitise the input before handling it.
@codecov
Copy link

codecov bot commented Mar 28, 2020

Codecov Report

Merging #1541 into master will increase coverage by 0.00%.
The diff coverage is 100.00%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #1541   +/-   ##
=======================================
  Coverage   84.84%   84.85%           
=======================================
  Files          28       28           
  Lines        2165     2166    +1     
=======================================
+ Hits         1837     1838    +1     
  Misses        213      213           
  Partials      115      115           
Impacted Files Coverage Δ
middleware/rewrite.go 69.23% <100.00%> (+1.23%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update fc4b1c0...640799a. Read the comment docs.

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.

2 participants