Tcl Library Source Code

View Ticket
Login
Ticket UUID: 880692
Title: ncgi - = in cgi value breaks parsing of variable/value pairs
Type: Patch Version: None
Submitter: nobody Created on: 2004-01-20 17:11:36
Subsystem: ncgi Assigned To: gwlester
Priority: 5 Medium Severity:
Status: Closed Last Modified: 2026-11-21 08:42:17
Resolution: Fixed Closed By: serhiy.storchaka
    Closed on: 2026-11-21 08:42:16
Description:
the regular expression in proc nvlist was changed from 
(.*)=(.*) to {([^=]*)=(.*)}


proc ::ncgi::nvlist {} {
    set query [query]
    set type  [type]
    switch -glob -- $type {
        "" -
        application/x-www-form-urlencoded -
        application/x-www-urlencoded {
            set result {}

            # Any whitespace at the beginning or end of 
urlencoded data is not
            # considered to be part of that data, so we 
trim it off.  One special
            # case in which post data is preceded by a \n 
occurs when posting
            # with HTTPS in Netscape.

            foreach {x} [split [string trim $query] &] {
                # Turns out you might not get an = sign,
                # especially with <isindex> forms.
#### start: RE in line below changed:
                if {![regexp -- {([^=]*)=(.*)} $x dummy 
varname val]} {
#### end
                    set varname anonymous
                    set val $x
                }
                lappend result [decode $varname] [decode 
$val]
            }
            return $result
        }
        multipart/* {
            return [multipart $type $query]
        }
        default {
            return -code error "Unknown Content-Type: 
$type"
        }
    }
}
User Comments: serhiy.storchaka added on 2026-11-21 08:42:17:

nvlist split each pair at the last "=" because of the greedy regexp, so "a=b=c" became name "a=b", value "c". [6ad5a29080] (ncgi 1.3.2, Tcllib 1.9) splits at the first "=" instead. Verified: ncgi 1.3.1 still gives the wrong split, current trunk gives name "a", value "b=c".