This is an automated email from the ASF dual-hosted git repository.
rmaucher pushed a commit to branch 11.0.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git
The following commit(s) were added to refs/heads/11.0.x by this push:
new bce83410ff Fix some issues with rewrite processing from code review
bce83410ff is described below
commit bce83410ffb1542752d52b536257e81a5c8dfcb8
Author: remm <[email protected]>
AuthorDate: Thu Jul 16 14:11:50 2026 +0200
Fix some issues with rewrite processing from code review
N should really start from 0.
C should start from after the last in the chain.
qsd should always discard the original query string (already done on
redirect).
Remove code that tries to edit urlStringEncoded with a dubious index.
Since it is reconstructed, there is no need to remove '?'.
Avoid possible loop parsing the configuration on IOE.
---
.../apache/catalina/valves/rewrite/RewriteValve.java | 18 +++++++++---------
1 file changed, 9 insertions(+), 9 deletions(-)
diff --git a/java/org/apache/catalina/valves/rewrite/RewriteValve.java
b/java/org/apache/catalina/valves/rewrite/RewriteValve.java
index b879128a7c..8c839254df 100644
--- a/java/org/apache/catalina/valves/rewrite/RewriteValve.java
+++ b/java/org/apache/catalina/valves/rewrite/RewriteValve.java
@@ -312,6 +312,7 @@ public class RewriteValve extends ValveBase {
}
} catch (IOException ioe) {
containerLog.error(sm.getString("rewriteValve.readError"),
ioe);
+ break;
}
}
this.mapsConfiguration = mapsConfiguration;
@@ -475,11 +476,7 @@ public class RewriteValve extends ValveBase {
REWRITE_QUERY_ENCODER.encode(rewrittenQueryStringRewriteEncoded, uriCharset));
urlStringEncoded.append('&');
urlStringEncoded.append(queryStringOriginalEncoded);
- } else if (index == urlStringEncoded.length() - 1)
{
- // if the ? is the last character delete it,
its only purpose was to
- // prevent the rewrite module from appending
the query string
- urlStringEncoded.deleteCharAt(index);
- } else {
+ } else if
(!rewrittenQueryStringRewriteEncoded.isEmpty()) {
urlStringEncoded.append('?');
urlStringEncoded.append(
REWRITE_QUERY_ENCODER.encode(rewrittenQueryStringRewriteEncoded, uriCharset));
@@ -538,12 +535,15 @@ public class RewriteValve extends ValveBase {
// - chain (skip remaining chained rules if this one does not
match)
if (rule.isChain() && newtest == null) {
- for (int j = i; j < rules.length; j++) {
+ int skip = 0;
+ for (int j = i + 1; j < rules.length; j++) {
if (!rules[j].isChain()) {
- i = j;
break;
+ } else {
+ skip++;
}
}
+ i += skip;
continue;
}
// - last (stop rewriting here)
@@ -552,7 +552,7 @@ public class RewriteValve extends ValveBase {
}
// - next (redo again)
if (rule.isNext() && newtest != null) {
- i = 0;
+ i = -1;
continue;
}
// - skip (n rules)
@@ -618,7 +618,7 @@ public class RewriteValve extends ValveBase {
request.getCoyoteRequest().queryString().setChars(MessageBytes.EMPTY_CHAR_ARRAY,
0, 0);
chunk =
request.getCoyoteRequest().queryString().getCharChunk();
chunk.append(REWRITE_QUERY_ENCODER.encode(queryStringRewriteEncoded,
uriCharset));
- if (qsa && queryStringOriginalEncoded != null &&
!queryStringOriginalEncoded.isEmpty()) {
+ if (!qsd && qsa && queryStringOriginalEncoded != null
&& !queryStringOriginalEncoded.isEmpty()) {
chunk.append('&');
chunk.append(queryStringOriginalEncoded);
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]