Skip to content
Tcl Source Code View Ticket
Login

View Ticket

formatQuery incorrectly encodes newlines

Closed / Rejected2914492fffffffffffffffffffffffffffffffffCreated 17 years agoUpdated 17 years ago
Descriptionplain2009-12-15 00:44:42
http::formatQuery is used for encoding name-value pairs for submission to forms.  It handles percent-escaping for reserved characters as specified in RFC3986 and its predecessors.  However, it also specially handles newlines, changing them into CRNL pairs.  This behavior is incorrect for a few reasons.
1. the line break -> CRNL behavior is specified in the HTML specification, not the URI specification, and is specifically intended for form data (i.e., a html textarea), and it mentions "line breaks" not "newlines".
2. the behavior makes it impossible to correctly upload a file as form POST data (without going into multipart madness)
3. Many other common packages (e.g., LWP, curl) do NOT do this translation (ncgi being a notable exception)
4. Few CGI packages undo this newline encoding. (ncgi is no exception here)
patthoytsplain2010-02-26 08:15:01
This is functionality that is explicitly tested for in the http package tests (see http-5.3) and has been here since the initial revision for which I have access from 1998. I have no idea how many users of tcl might be affected detrimentally by changing this but it seems likely to be a problem for some of them.

The implementation here is of application/x-www-url-encoded and the specification for this form submission encoding explicitly states the \n to %0d%0a mapping. See http://www.w3.org/TR/html401/interact/forms.html#h-17.13.4.1 where it states: 
"Line breaks, as in multi-line text field values, are represented as CR LF pairs, i.e. `%0D%0A'."

The implementation is therefore correctly following the specification.
patthoyts Pending ticket [2914492fff]. [History diff]2010-02-26 08:15:02
sf-robotplain2010-03-12 09:20:34
allow_comments - 1

This Tracker item was closed automatically by the system. It was
previously set to a Pending status, and the original submitter
did not respond within 14 days (the time period specified by
the administrator of this Tracker).
Log in (anonymous is fine) to add a comment.