Tcl Library Source Code

Artifact [103a2a9169]
Login
EuroTcl/OpenACS 11 - 12 JULY 2024, VIENNA

Artifact 103a2a916946d18b055329144caa2f2a56f1b5918560dff7e5a8b3d69c6961f9:

Attachment "063e7a95be.patch" to ticket [063e7a95be] added by anonymous 2018-06-01 17:03:48. (unpublished)
diff --git a/modules/ncgi/ncgi.tcl b/modules/ncgi/ncgi.tcl
index 70a96c1..fcedc6e 100644
--- a/modules/ncgi/ncgi.tcl
+++ b/modules/ncgi/ncgi.tcl
@@ -815,7 +815,7 @@ proc ::ncgi::header {{type text/html} args} {
 #	parameters.  Given the above example, the return value is
 #	{
 #		value
-#		{param value param2 value param3 value3}
+#		{param value param2 value2 param3 value3}
 #	}
 
 proc ::ncgi::parseMimeValue {value} {
@@ -827,11 +827,10 @@ proc ::ncgi::parseMimeValue {value} {
             set key [string trim [string tolower $key]]
             set val [string trim $val]
             # Allow single as well as double quotes
-            if {[regexp -- {^["']} $val quote]} { ;# need a " for balance
-                if {[regexp -- ^${quote}(\[^$quote\]*)$quote $val x val2]} {
-                    # Trim quotes and any extra crap after close quote
-                    set val $val2
-                }
+            if {[regexp -- {^(['"])(.*)\1} $val x quote val2]} { ; # need a " for balance
+               # Trim quotes and any extra crap after close quote
+               # remove quoted quotation marks
+               set val [string map {\\" "\"" \\' "\'"} $val2]
             }
             lappend paramList $key $val
 	}
diff --git a/modules/ncgi/ncgi.test b/modules/ncgi/ncgi.test
index 5089a24..589b34d 100644
--- a/modules/ncgi/ncgi.test
+++ b/modules/ncgi/ncgi.test
@@ -578,6 +578,14 @@ test ncgi-13.6 {ncgi::parseMimeValue} {
     ncgi::parseMimeValue "text/html; charset=\"iso-8859-1\"morecrap"
 } {text/html {charset iso-8859-1}}
 
+test ncgi-13.7 {ncgi::parseMimeValue} {
+    ncgi::parseMimeValue {test/test; foo="bar\"baz\""}
+} {test/test {foo bar\"baz\"}}
+
+test ncgi-13.8 {ncgi::parseMimeValue} {
+    ncgi::parseMimeValue {test/test; foo=""}
+} {test/test {foo {}}}
+
 
 test ncgi-14.1 {ncgi::multipart} {
     catch {ncgi::multipart "application/x-www-urlencoded" name=val+ue} err