Open xzxzxc opened 4 years ago
Happy to take a crack at this if at all helpful. Looks like there are several other little quirks throughout the apache compatibility subsystem that break parity with apache itself that I'd be happy to submit PRs for.
I just ran into this on a new proj. Simple things like \d can be changed to [0-9] and . to [.] but \w and \s and others which represent a lot of chars are basically show-stoppers for using this feature with regex rules.
Also just realized RewriteMap is not supported :/ Guess I'll convert all the rules to IISUrlRewrite format (hopefully that works fully).
This call should probably be renamed to AddApacheModRewriteWithOnlyLimitedSupport, so people like me know not to use it before we write a bunch of rules expected everything to work correctly.
Happy to take a crack at this if at all helpful.
@jaamison it looks like we overlooked your offer, sorry about that. In the unlikely event you are still interested in offering PR's we'd be happy to have them.
Description of the bug
The System.ArgumentException occurs while executing the method AddApacheModRewrite if passed file contains regex rules with shorthand character classes (like \d).
To Reproduce
Where file
apache_rewrite_rules.txt
contains:RewriteRule ^/(\d)$ /?num=$1
Exception message:
System.ArgumentException: 'parsing '^/(\d)$' - Unrecognized escape sequence \\d.'
Stack trace:Comments
RewriteRule statement implies to use regular expressions, so it's not clear why there is a call of
Regex.Unescape
inApacheModRewrite.Tokenizer.RemoveQuotesAndEscapeCharacters
, seems like it's a bug considering thatRegex.Unescape
is unable to convert sequences such as \w, \d or \s, it throws an ArgumentException.