| Description: |
Obtaining the results of form submissions where a
field contains a large amount of data ( >5-10kb )
causes the CPU to max out for long periods of time
(several minutes for 40kb on a reasonably fast PC).
The problem is caused by the regular expression:
regexp -- (.*)=(.*) $x dummy varname val
which doesn't seem to handle really large strings well.
My fix was to use the following:
set pos [string first "=" $x]
set len [string length $x]
if { $pos>=0 } {
if { $pos == 0 } { # if the = is at the
beginning ...
if { $len>1 } { # ... and there is something
to the right ...
set varname anonymous
set val [string range $x 1 [expr $len-1]]
} else { # ... otherwise, all we have is an =
set varname anonymous
set val ""
}
} elseif { $pos==[expr $len-1] } { # if the = is
at the end ...
set varname [string range $x 0 [expr $pos-1]]
set val ""
} else {
set varname [string range $x 0 [expr $pos-1]]
set val [string range $x [expr $pos+1] [expr
$len-1]]
}
} else { # no = was found ...
set varname anonymous
set val $x
}
in place of:
if {![regexp -- (.*)=(.*) $x dummy varname val]} {
set varname anonymous
set val $x
}
in ncgi::nvlist in tcllib/ncgi. I know that the
problem exists in tcllib version 1.1 and 1.2.
|