Bug 60116 - NC matches in the Rewrite Valve cause matched groups to be lower case.
Summary: NC matches in the Rewrite Valve cause matched groups to be lower case.
Status: RESOLVED FIXED
Alias: None
Product: Tomcat 8
Classification: Unclassified
Component: Catalina (show other bugs)
Version: 8.5.x-trunk
Hardware: All All
: P2 normal (vote)
Target Milestone: ----
Assignee: Tomcat Developers Mailing List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-09-12 07:08 UTC by Sebastiaan van Erk
Modified: 2016-09-12 22:19 UTC (History)
0 users



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Sebastiaan van Erk 2016-09-12 07:08:46 UTC
I have the following rewrite rule:

RewriteCond %{REQUEST_URI} /test
RewriteCond %{QUERY_STRING} .*a=([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}).* [NC]
RewriteRule .* - [E=X-Tenant-Id:%1,L]

This matches the query string to the supplied pattern in a case insensitive way. However, the back reference %1 is always lower case, independent of the actual query string. That is, if the query string is:

    http://localhost:8080/test?a=CFA2AFDF-5D36-4D1F-B798-430557CF4355

the matched back reference %1 is cfa2afdf-5d36-4d1f-b798-430557cf4355.

This is strange and unexpected. It is also not how NC works in The Apache HTTP server mod_rewrite, which just does the test in a case insensitive way but returns the actual matched group. Case insensitive Java regular expressions also do not change the case of any of the matched groups.
Comment 1 Mark Thomas 2016-09-12 22:19:44 UTC
This has been fixed in the following branches:
- 9.0.x for 9.0.0.M11 onwards
- 8.5.x for 8.5.6 onwards
- 8.0.x for 8.0.38 onwards