URl checking too strict when using multiple question marks
Closed / Fixed2891171fffffffffffffffffffffffffffffffffCreated 17 years agoUpdated 17 years ago
Descriptionplain2009-11-03 10:11:14
Trying the following requiest through IE works fine:
http://165.114.214.221/getParam.cgi?AIValue_00=?
reply: AIValue_00=28192
Doing the same through TCL:
% package require http
2.7
% set url http://165.114.214.221
http://165.114.214.221
% set reply [::http::geturl ${url}/getParam.cgi?AIValue=?]
Unsupported URL: http://165.114.214.221/getParam.cgi?AIValue=?
%
Analisis: The following line in the URLmatcher variable:
( / [^\#?]* (?: \? [^\#?]* )?)? # <path> (including query)
Checks if the <path> part of the URL contains exactly
one question mark. According through RFC 3986 this
is how an URL should look like, but apparently there
are URL's that violate this. There is no reason to
restruct URL's this way, so I think the regular
expression should be relaxed.
Suggestion: replace the mentioned line with:
( / [^\#]*)? # <path> (including query)
should do the trick.
If no-one objects, I will check this change in, in
a few days.
dkfplain2009-11-03 17:47:42
A '?' in the request parameter should be encoded as '%3f'.
nijtmansplain2009-11-03 18:02:42
>A '?' in the request parameter should be encoded as '%3f'. Yes, that was my first though too. But in this case, the question mark is not used as a value, it is a separator, so encoding it as %3f does not work with this service.
dkfplain2009-11-03 18:47:39
Does it work in any browser other than IE? If not, it's just a broken site and we shouldn't introduce breakage into the http package just to allow for this one stupidity. As evidence, I cite RFC 1738 which states that "?" is one of the reserved characters in the <searchpart> (the part of the query after the first "?" character).
coldstoreplain2009-11-03 18:58:26
Can't you get the server fixed?
matzekplain2009-11-03 19:01:34
I am also against such a move. If this is really needed and going to be implemented, please ensure it either has to be explicitly switched on, or can at least be switched off... -- Matthias Kraft
nijtmansplain2009-11-03 19:14:33
So, I am glad I brought this up. So many reactions. Thanks all!
Answerings: Yes Firefox and other browsers behave the same
way. No browser does automatic URL-encoding. They all
pas through the exact URL given.
No, I cannot get the server fixed. RFC 1738 is
indeed rather misleading in the interpretation
of what is allowed in the <query> part of an URL.
Lucky enough, RFC 3986 has a much clearer
description, which convinced me that multiple
question marks are allowed in a quiery. Citing:
this RFC:
===================================
3.4. Query
The query component contains non-hierarchical data that, along with
data in the path component (Section 3.3), serves to identify a
resource within the scope of the URI's scheme and naming authority
(if any). The query component is indicated by the first question
mark ("?") character and terminated by a number sign ("#") character
or by the end of the URI.
query = *( pchar / "/" / "?" )
The characters slash ("/") and question mark ("?") may represent data
within the query component. Beware that some older, erroneous
implementations may not handle such data correctly when it is used as
the base URI for relative references (Section 5.1), apparently
because they fail to distinguish query data from path data when
looking for hierarchical separators. However, as query components
are often used to carry identifying information in the form of
"key=value" pairs and one frequently used value is a reference to
another URI, it is sometimes better for usability to avoid percent-
encoding those characters.
dgpplain2009-11-10 22:58:50
nijtmans, please commit your patch to go in http 2.7.4 distributed with Tcl 8.5.8 and 8.6b2. Thanks.
dgp Ticket [2891171fff]: 1 change
[History diff]2009-11-10 22:58:51
patthoytsplain2009-11-10 23:03:26
When the strict uri checking code went in (during 8.5 development iirc) it got a -strict option added to disable it. So http::geturl $uri -strict 0 will probably have let you work with this as it stands. However, I would support changing this to match the URI rfc as you've quoted below. We are evidently being too strict. No objection.
patthoyts Ticket [2891171fff]: 1 change
[History diff]2009-11-10 23:03:27
matzekplain2009-11-11 03:53:21
I hereby withdraw my objection :-) ... I read through the RFCs and it seems I indeed had the wrong impression that there is a strict definition of the last part of the URL notation. -- Matthias Kraft
dkfplain2009-11-11 19:47:01
I see that you committed a fix for this. Are you going to backport?
nijtmansplain2009-11-11 19:55:44
Yes, I am planning to backport this, but I cannot do it until tonight. Don, feel free to do it, if you are waiting for it in order to complete the 8.5.8 release.....
dgpplain2009-11-11 23:00:31
sorry about the bad advice. I had forgotten that the http packages on the 8-5 and 8-6 branches had already diverged.
dgpplain2009-11-11 23:15:16
allow_comments - 1 backport to http 2.7.5 (distributed with Tcl 8.5.8) completed.
Log in (anonymous is fine) to add a comment.