Skip to content

Commit 75d1152

Browse files
committed
Update RewriteValve to use dotall mode
1 parent b01c241 commit 75d1152

File tree

3 files changed

+8
-3
lines changed

3 files changed

+8
-3
lines changed

java/org/apache/catalina/valves/rewrite/RewriteCond.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ public void parse(Map<String, RewriteMap> maps) {
151151
this.condition = ncondition;
152152
} else {
153153
PatternCondition ncondition = new PatternCondition();
154-
int flags = 0;
154+
int flags = Pattern.DOTALL;
155155
if (isNocase()) {
156156
flags |= Pattern.CASE_INSENSITIVE;
157157
}

java/org/apache/catalina/valves/rewrite/RewriteRule.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public void parse(Map<String, RewriteMap> maps) {
4747
positive = false;
4848
patternString = patternString.substring(1);
4949
}
50-
int flags = 0;
50+
int flags = Pattern.DOTALL;
5151
if (isNocase()) {
5252
flags |= Pattern.CASE_INSENSITIVE;
5353
}
@@ -89,7 +89,7 @@ public CharSequence evaluate(CharSequence url, Resolver resolver) {
8989
Pattern pattern = this.pattern.get();
9090
if (pattern == null) {
9191
// Parse the pattern
92-
int flags = 0;
92+
int flags = Pattern.DOTALL;
9393
if (isNocase()) {
9494
flags |= Pattern.CASE_INSENSITIVE;
9595
}

webapps/docs/changelog.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,11 @@
147147
<code>ErrorReportValve</code> that returns response as JSON instead of
148148
HTML. Back-porting kfujino's implementation. (lihan)
149149
</add>
150+
<fix>
151+
Update the <code>RewriteValve</code> to perform pattern matching using
152+
dotall mode to avoid unexpected behaviour if the URL includes encoded
153+
line terminators. (markt)
154+
</fix>
150155
</changelog>
151156
</subsection>
152157
<subsection name="Coyote">

0 commit comments

Comments
 (0)