]> git.ipfire.org Git - thirdparty/apache/httpd.git/commitdiff
revert recent r1910650
authorEric Covener <covener@apache.org>
Wed, 28 Jun 2023 12:27:33 +0000 (12:27 +0000)
committerEric Covener <covener@apache.org>
Wed, 28 Jun 2023 12:27:33 +0000 (12:27 +0000)
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1910661 13f79535-47bb-0310-9956-ffa450edef68

modules/mappers/mod_rewrite.c

index 0ead238e64f6d64b87144988a7e16178b76f1ce0..7fb4e92c0de1a9bd182009e95b3e4eed9714ee49 100644 (file)
@@ -806,6 +806,12 @@ static void splitout_queryargs(request_rec *r, int flags)
     int qsdiscard = flags & RULEFLAG_QSDISCARD;
     int qslast = flags & RULEFLAG_QSLAST;
 
+    if (flags & RULEFLAG_QSNONE) {
+        rewritelog(r, 2, NULL, "discarding query string, no parse from substitution");
+        r->args = NULL;
+        return;
+    }
+
     /* don't touch, unless it's a scheme for which a query string makes sense.
      * See RFC 1738 and RFC 2368.
      */
@@ -847,10 +853,6 @@ static void splitout_queryargs(request_rec *r, int flags)
                r->args[len-1] = '\0';
            }
         }
-        if (flags & RULEFLAG_QSNONE) {
-            rewritelog(r, 2, NULL, "discarding query string, no parse from substitution");
-            r->args = NULL;
-        }
 
         rewritelog(r, 3, NULL, "split uri=%s -> uri=%s, args=%s", olduri,
                    r->filename, r->args ? r->args : "<none>");
@@ -3907,15 +3909,15 @@ static const char *cmd_rewriterule(cmd_parms *cmd, void *in_dconf,
     }
 
     if (*(a2_end-1) == '?') {
-        if (!(newrule->flags & RULEFLAG_QSAPPEND) &&
-            !(newrule->flags & RULEFLAG_QSLAST)) {
-            /* Rule ends with a literal ?, make sure we don't end up with any query */
+        *(a2_end-1) = '\0'; /* trailing ? has done its job */
+        /* a literal ? at the end of the unsubstituted rewrite rule */
+        if (!(newrule->flags & RULEFLAG_QSAPPEND))
+        {
             newrule->flags |= RULEFLAG_QSNONE;
         }
     }
     else if (newrule->flags & RULEFLAG_QSDISCARD) {
         if (NULL == ap_strchr(newrule->output, '?')) {
-            /* QSD and no literal ? in substitution, make sure we don't end up with any query */
             newrule->flags |= RULEFLAG_QSNONE;
         }
     }