Fix header name-value parsing
(1.1) By Oleg (oleg4tcltk) on 2020-06-08 13:31:21 edited from 1.0 [source]
Hi.
This patch fix name-value parsing according to rfc7230(sect 3.2). Field name shouldn't contain ':' char and white space after ':' is optional and white space before and after field value should be removed.
--- a/wapp.tcl
+++ b/wapp.tcl
@@ -589,7 +589,7 @@ proc wappInt-parse-header {chan} {
set n [llength $hdr]
for {set i 1} {$i<$n} {incr i} {
set x [lindex $hdr $i]
- if {![regexp {^(.+): +(.*)$} $x all name value]} {
+ if {![regexp {^([^:]+):[[:blank:]]*(.*?)[[:blank:]]*$} $x all name value]} {
error "invalid header line: \"$x\""
}
set name [string toupper $name]