# HG changeset patch # User Matti Hamalainen # Date 1611517647 -7200 # Node ID 9b64f201b3a72c9a2e7a3a1571eb8722a4aaf1ad # Parent d5fc3ecee4c7ca381682227c6212411ac13bab7a urllog: Use lowercase HTTP metadata keys and sanitize them. diff -r d5fc3ecee4c7 -r 9b64f201b3a7 urllog.tcl --- a/urllog.tcl Sun Jan 10 14:57:30 2021 +0200 +++ b/urllog.tcl Sun Jan 24 21:47:27 2021 +0200 @@ -229,6 +229,12 @@ array set umeta [::http::meta $utoken] ::http::cleanup $utoken + # Sanitize the metadata KEYS + foreach {ukey uvalue} [array get umeta] { + set ukey [string tolower $ukey] + set umeta($ukey) $uvalue + } + return 1 } @@ -349,7 +355,7 @@ ### Handle redirects if {$ucode >= 301 && $ucode <= 303} { - set nurlStr $umeta(Location) + set nurlStr $umeta(location) if {![regexp "\[a-z\]+://" $nurlStr]} { if {[string range $nurlStr 0 0] != "/"} { append nurlStr "/" @@ -370,7 +376,7 @@ ### Handle 2nd level redirects if {$ucode >= 301 && $ucode <= 303} { - set nurlStr $umeta(Location) + set nurlStr $umeta(location) if {![regexp "\[a-z\]+://" $nurlStr]} { if {[string range $nurlStr 0 0] != "/"} { append nurlStr "/" @@ -396,7 +402,7 @@ set uencoding "" # Get information about specified character encodings - if {[info exists umeta(Content-Type)] && [regexp -nocase {charset\s*=\s*([a-z0-9._-]+)} $umeta(Content-Type) umatches uenc_http]} { + if {[info exists umeta(Content-Type)] && [regexp -nocase {charset\s*=\s*([a-z0-9._-]+)} $umeta(content-type) umatches uenc_http]} { # Found character set encoding information in HTTP headers }