Skip to content
Tcl Source Code View Ticket
Login

View Ticket

2000-10-26
08:27 • Closed ticket [218697ffff]: Regexp Error plus 4 other changes artifact: 07b52d1fb9 user: welch
01:04 • New ticket [218697ffff]. artifact: 96a190a289 user: nobody

Regexp Error

Closed / Fixed218697ffffffffffffffffffffffffffffffffffCreated 26 years agoUpdated 26 years ago
Descriptionplain2000-10-26 01:04:14
OriginalBugID: 1780 Bug
Version: 8.1b3
SubmitDate: '1999-04-12'
LastModified: '1999-08-07'
Severity: MED
Status: Released
Submitter: pat
ChangedBy: hobbs
OS: Windows 95
Machine: X86
FixedDate: '1999-08-07'
FixedInVersion: 8.2
ClosedDate: '2000-10-25'


Name:
Chang LI

Extensions:
none

CustomShell:
none

ReproducibleScript:
Followig code product error result in Tcl8.1b3, but correct in 8.0.
    
    #
    #Reportreport the exception
    #statusserver status
    #keywordshort description
    #messagedetail description
    #
    proc Report {status keyword message} {
    puts "
    Status:$status
    Keyword:$keyword
    Message:$message
    "
    }
    
    #
    #ParseFormparse CGI string
    #aFormInforeturn form info array
    # ReturnRESULT_OK or RESULT_ERROR
    #
    proc ParseForm {aFormInfo} {
    upvar $aFormInfo sFormData
    
    set sReqMethod $::env(REQUEST_METHOD)
    switch -exact -- $sReqMethod {
    POST {set sQuery [read stdin $::env(CONTENT_LENGTH)]}
    GET{set sQuery $::env(QUERY_STRING)}
    default {Report  500 "server error" "unsupport method"
     return RESULT_ERROR}
    }
    
    set pairs [split $sQuery &]
    foreach item $pairs {
    set pair [split $item =]
    set key [lindex $pair 0]
    set value [lindex $pair 1]
    
    regsub -all {\+} $value { } value
    
    while {[regexp {%[0-9A-Fa-f][0-9A-Fa-f]} $value matched]} {
    scan $matched "%%%x" hex
    set symbol [format %c $hex]
    regsub -all $matched $value $symbol value
    }
    
    if {[info exists sFormData($key)]} {
    append sFormData($key) "\0" $value
    } else {
    set sFormData($key) $value
    }
    }
    return RESULT_OK
    }
    
    set ::env(REQUEST_METHOD) GET
    set ::env(QUERY_STRING)
    {user=Larry%20Bird&age=35&pass=testing&user=Wong}
    
    if {[string compare [ParseForm sForm] RESULT_OK] == 0} {
    puts "user=$sForm(user) age=$sForm(age)"
    }

ObservedBehavior:
output a high 8 bit character. 
    repeat execute with source "$filenme" to run this code get append 
    output string.

DesiredBehavior:
The output is a simple string.



This works as desired in 8.2, fix must have been done along the way. 
-- 08/07/1999 hobbs
welch Closed ticket [218697ffff]. [History diff]2000-10-26 08:27:11
Log in (anonymous is fine) to add a comment.