Bug 33112 - Query_string not preserved after content negotiation
Summary: Query_string not preserved after content negotiation
Status: RESOLVED FIXED
Alias: None
Product: Apache httpd-2
Classification: Unclassified
Component: mod_negotiation (show other bugs)
Version: 2.2.14
Hardware: All Linux
: P2 normal (vote)
Target Milestone: ---
Assignee: Apache HTTPD Bugs Mailing List
URL:
Keywords: FixedInTrunk, PatchAvailable
: 43550 (view as bug list)
Depends on:
Blocks:
 
Reported: 2005-01-15 13:56 UTC by Joergen Thomsen
Modified: 2010-10-06 07:57 UTC (History)
2 users (show)



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Joergen Thomsen 2005-01-15 13:56:52 UTC
The query string is not preserved when returning the negotiated file causing CGI 
scripts to miss all request variables. Here is a fix:

--- httpd-2.0.52/modules/mappers/mod_negotiation.c      2004-02-09 21:53:18.
000000000 +0100
+++ httpd-2.0.52j/modules/mappers/mod_negotiation.c     2005-01-15 13:47:20.
095964578 +0100
@@ -2938,7 +2938,7 @@
     udir = ap_make_dirstr_parent(r->pool, r->uri);
     udir = ap_escape_uri(r->pool, udir);
     ap_internal_redirect(apr_pstrcat(r->pool, udir, best->file_name,
-                                     r->path_info, NULL), r);
+                                     r->path_info, "?", r->args, NULL), r);
     return OK;
 }

@@ -2991,6 +2991,7 @@
             goto return_from_multi;
         }
     }
+    if ((r->args != NULL) && ( sub_req->args == NULL)) sub_req->args = 
apr_pstrdup(r->pool, r->args);    /* keep query_string */

     /* now do a "fast redirect" ... promotes the sub_req into the main req */
     ap_internal_fast_redirect(sub_req, r);
Comment 1 Per Jessen 2007-08-14 01:55:10 UTC
Also present in 2.2.4.
Comment 2 Nick Kew 2007-08-14 02:23:20 UTC
Fixed in trunk: http://svn.apache.org/viewvc?view=rev&revision=565671
Comment 3 Per Jessen 2007-08-14 03:46:24 UTC
It's probably irrelevant now, but I've applied and tested the patch in 2.2.4.
Works fine.
Comment 4 Nick Kew 2007-08-28 16:43:29 UTC
Fixed for 2.2.6.
Comment 5 Joergen Thomsen 2008-10-05 16:06:27 UTC
This part has disappeared from mod_negotiation.c
 
+    if ((r->args != NULL) && ( sub_req->args == NULL)) sub_req->args = apr_pstrdup(r->pool, r->args);    /* keep query_string */

Please, enter it.

Comment 6 Ruediger Pluem 2008-10-06 00:55:29 UTC
(In reply to comment #5)
> This part has disappeared from mod_negotiation.c
> 
> +    if ((r->args != NULL) && ( sub_req->args == NULL)) sub_req->args =
> apr_pstrdup(r->pool, r->args);    /* keep query_string */
> 
> Please, enter it.
> 

It was never in the code as the bug was fixed differently (see
http://svn.apache.org/viewvc?view=rev&revision=565671 and http://svn.eu.apache.org/viewvc?view=rev&revision=570450) . Unless the problem still occurs for you please leave this bug closed.
Comment 7 Joergen Thomsen 2008-10-06 02:17:32 UTC
Please, don't close bugs, you haven't tested !
Why do you think I have reopened this bug ?!

I have added the missing line and now it is working.
It is not working as released in 2.2.9 
Comment 8 Per Jessen 2009-02-22 08:23:28 UTC
I've just "rediscovered" the issue in 2.2.4. I upgraded to 2.2.11, and that solved problem for me.
Comment 9 Eric Covener 2009-02-22 10:45:38 UTC
I also couldn't reproduce with recent 2.2.x, please provide a detailed report against 2.2.6 or later if re-opening.
Comment 10 Joergen Thomsen 2009-02-22 13:29:41 UTC
I have also checked 2.2.11 and the problem has been fixed.

Looking at the fixed issues in 2.2.10 in 2.2.11 I suspect, that this somehow was the causing the problem i.e. same symptom, but in another module.

Bug 45247 - query string not preserved with [proxy, noescape]
Comment 11 Joergen Thomsen 2009-09-15 11:50:27 UTC
Apparently this bug will not fully die.
I still have to add this line in 2.2.13

    if ((r->args != NULL) && ( sub_req->args == NULL)) sub_req->args = apr_pstrdup(r->pool, r->args);    /* keep query_string JTH */

at line 3134 in mod_negotiation.c

Without this line this will not work (params not recognized)

http://jth.net/index?scroll=yes&ramme=./domchange.da.php

 [QUERY_STRING] => 
 [REQUEST_URI] => /index?scroll=yes&ramme=./domchange.da.php

but

http://jth.net/index.var?scroll=yes&ramme=./domchange.da.php

 [QUERY_STRING] => scroll=yes&ramme=./domchange.da.php
 [REQUEST_URI] => /index?scroll=yes&ramme=./domchange.da.php
 [REDIRECT_URL_COUNT_DINDEX] => index1.php index.var index.da.php index.php index.html index.htm index.shtml index.cgi index.html.da index.html.en index
 
will.

index.var contains

URI: index

URI: index.da.php
Content-type: text/html

URI: index.en.php
Content-type: text/html
Content-language: en, de, fr

URI: index.nl.php
Content-type: text/html
Content-language: nl

URI: index.da.php
Content-type: text/html
Content-language: da, sv, no, fo, is
Comment 12 Joergen Thomsen 2010-02-22 17:35:54 UTC
Still not solved in 2.2.14
Comment 13 Nick Kew 2010-02-23 16:16:54 UTC
OK, you have a scenario where mod_negotiation runs twice: first to resolve multiviews, then to resolve a type map.  I am able to reproduce what you describe in Comment 11.

So the conclusion is: the same bug appeared in both handlers.  I fixed one ( Comment 2 ) and thought from the comments (including Comment 10 from you) all was well - hence the confusion.

Looks like your fix will do the job, and we can dispense with the copy so it's virtually overhead-free.  Applied now in r915407 .
Comment 14 Ruediger Pluem 2010-02-23 20:07:24 UTC
*** Bug 43550 has been marked as a duplicate of this bug. ***
Comment 15 Rainer Jung 2010-09-28 07:01:16 UTC
The patch in r915407 has been backported to 2.2 as r917017 and is part of the released version 2.2.15.
Comment 16 Rainer Jung 2010-10-06 07:57:05 UTC
The patch has also been backported to 2.0 as revision r1004972 and will be part of version 2.0.64 and beyond once it gets released.