diff options
author | Yann Ylavic <ylavic@apache.org> | 2024-09-11 16:13:54 +0200 |
---|---|---|
committer | Yann Ylavic <ylavic@apache.org> | 2024-09-11 16:13:54 +0200 |
commit | a8be4c58f6a989e2a112c6981679d296438978ad (patch) | |
tree | 08169a80af5d80212d2c7400d19bbebc28c1f6f9 | |
parent | Windows: fix "Include" of UNC paths (diff) | |
download | apache2-a8be4c58f6a989e2a112c6981679d296438978ad.tar.xz apache2-a8be4c58f6a989e2a112c6981679d296438978ad.zip |
mod_rewrite: Follow up to r1919325: Simplify QSLAST tracking.
We don't need to loop to skip the safe qmarks (thanks rpluem!).
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1920566 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r-- | modules/mappers/mod_rewrite.c | 32 |
1 files changed, 14 insertions, 18 deletions
diff --git a/modules/mappers/mod_rewrite.c b/modules/mappers/mod_rewrite.c index 10ba41a9b5..413eb417c2 100644 --- a/modules/mappers/mod_rewrite.c +++ b/modules/mappers/mod_rewrite.c @@ -2429,21 +2429,19 @@ static char *do_expand(char *input, rewrite_ctx *ctx, rewriterule_entry *entry, *unsafe_qmark = 0; /* keep tracking only if interested in the last qmark */ - if (entry && (entry->flags & RULEFLAG_QSLAST)) { - do { - span++; - span += strcspn(input + span, EXPAND_SPECIALS "?"); - } while (input[span] == '?'); - } - else { + if (!entry || !(entry->flags & RULEFLAG_QSLAST)) { unsafe_qmark = NULL; - span += strcspn(input + span, EXPAND_SPECIALS); } + + /* find the next real special char, any (last) qmark up to + * there is safe too + */ + span += strcspn(input + span, EXPAND_SPECIALS); } } - /* fast exit */ - if (inputlen == span) { + /* fast path (no specials) */ + if (span >= inputlen) { return apr_pstrmemdup(pool, input, inputlen); } @@ -2625,16 +2623,14 @@ static char *do_expand(char *input, rewrite_ctx *ctx, rewriterule_entry *entry, *unsafe_qmark = 0; /* keep tracking only if interested in the last qmark */ - if (entry && (entry->flags & RULEFLAG_QSLAST)) { - do { - span++; - span += strcspn(p + span, EXPAND_SPECIALS "?"); - } while (p[span] == '?'); - } - else { + if (!entry || !(entry->flags & RULEFLAG_QSLAST)) { unsafe_qmark = NULL; - span += strcspn(p + span, EXPAND_SPECIALS); } + + /* find the next real special char, any (last) qmark up to + * there is safe too + */ + span += strcspn(p + span, EXPAND_SPECIALS); } } if (span > 0) { |