Tcl Library Source Code

View Ticket
Login
Ticket UUID: 2861189
Title: decode and encode: inconsistent handling of line breaks
Type: Bug Version: None
Submitter: thomasmaeder Created on: 2009-09-18 06:13:43
Subsystem: ncgi Assigned To: welch
Priority: 5 Medium Severity:
Status: Closed Last Modified: 2026-11-21 11:06:49
Resolution: By Design Closed By: serhiy.storchaka
    Closed on: 2026-11-21 11:06:48
Description:
ncgi::encode (and http::formatQuery, for that matter) encodes "\n" as "%0d%0a". ncgi::decode decodes this sequence into "\r\n".

The result is that if a multi-line string is passed from a program to a CGI script that uses ncgi for dealing with the parameters, the CGI script doesn't see the same string the program intended to send it.

If implemented correctly, ncgi::encode and ncgi::decode should therefore be inverse operations, and the one to be adapted seems to be ncgi::decode.
User Comments: serhiy.storchaka added on 2026-11-21 11:06:49:

application/x-www-form-urlencoded requires line breaks as CR LF, so encode sends %0D%0A, like browsers and http::formatQuery, and decode returns what was sent. Use string map {\r\n \n} on the receiving side if you want LF.