Skip to content

Commit

Permalink
mod_rewrite: Follow up to r1919325: Simplify QSLAST tracking.
Browse files Browse the repository at this point in the history
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
  • Loading branch information
ylavic committed Sep 11, 2024
1 parent 6e9594c commit a8be4c5
Showing 1 changed file with 14 additions and 18 deletions.
32 changes: 14 additions & 18 deletions modules/mappers/mod_rewrite.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit a8be4c5

Please sign in to comment.