From dd19de9860747c84b40cfbce04302383ae759d40 Mon Sep 17 00:00:00 2001 From: Aleteoryx Date: Fri, 22 Nov 2024 20:13:32 -0500 Subject: [PATCH] fixes --- bin/up.tcl | 10 +++++++++- lib/atpagent.tcl | 6 +++--- plume.png | Bin 0 -> 6265 bytes src/httpd.tcl | 15 ++++++++++++++- 4 files changed, 26 insertions(+), 5 deletions(-) create mode 100644 plume.png diff --git a/bin/up.tcl b/bin/up.tcl index 3c80b45..1dacd16 100755 --- a/bin/up.tcl +++ b/bin/up.tcl @@ -56,7 +56,15 @@ if {$conf(avatar) != {}} { puts "upload: $av_data" if {$av_ncode != 200} { return -code error "got $av_ncode uploading avatar!\n$av_data" } - set avatarRef [list avatar [::json::write string $av_data]] + # this sucks. + set blob [::json::write object \ + {$type} {"blob"} \ + mimeType [::json::write string [dict get $av_data blob mimeType]] \ + size [dict get $av_data blob size] \ + ref [::json::write object \ + {$link} [::json::write string [dict get $av_data blob ref {$link}]]]] + + set avatarRef [list avatar $blob] puts $avatarRef } diff --git a/lib/atpagent.tcl b/lib/atpagent.tcl index bb6053d..d0d1f0b 100644 --- a/lib/atpagent.tcl +++ b/lib/atpagent.tcl @@ -43,14 +43,14 @@ proc atpagent_inner {statename cmd argv} { set ncode [::http::ncode $http_state] set data [::json::json2dict [::http::data $http_state]] - return [list $ncode $data] + return [list $ncode $data [::http::data $http_state]] } # POST path set mime "application/json" if {[lindex $rest 0] == "-type"} { - set rest [lasign $rest _ mime] + set rest [lassign $rest _ mime] } if {[llength $rest] > 1 && $mime == "application/json"} { @@ -65,7 +65,7 @@ proc atpagent_inner {statename cmd argv} { set ncode [::http::ncode $http_state] set data [::json::json2dict [::http::data $http_state]] - return [list $ncode $data] + return [list $ncode $data [::http::data $http_state]] } state { dict get $state {*}$argv diff --git a/plume.png b/plume.png new file mode 100644 index 0000000000000000000000000000000000000000..444ec8df60c7119fa2b725f5744b6143d3a2f2ed GIT binary patch literal 6265 zcmV-<7>4JGP)4Tx0C=30S7|g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<5q+xybdmDTclPtjbem=)!75MCRhD^I zWa)|w13e+>+41_mA3intf8Tp#G)t2Gz%JkrrJHRoVrjV?mR!6`1^bJIeOw?JZr)UL%Ra7ENH8w=j&W{cco!Rls_mA(}@$zreBilfM_(NKab;ESdnQjDfA{9W$EKnvu1}me zIu9HL#yZclT*i>F94txjFOJl&Z`R!(HqM&%#wQ;5=HR#f?NLfW*8?|E_Tpmr%mYo9 zIc=AXEkmufo1Q=W;`g7PIrYbPfBGMR_fVefE6P((+j(@36W_!ttxitn8d#vPDVC7^5n;WJAj+Hz$yM)0ufP?M*d-3ZWa^x&7Ha{ jtgylgE3B}>HN~$0$v!=??W6T*00000NkvXXu0mjf_xUpP literal 0 HcmV?d00001 diff --git a/src/httpd.tcl b/src/httpd.tcl index 52cf96a..eba9338 100644 --- a/src/httpd.tcl +++ b/src/httpd.tcl @@ -4,6 +4,19 @@ namespace eval ::httpd { variable log [logger::init httpd] variable routes + # https://wiki.tcl-lang.org/page/url-encoding + proc ::httpd::uri-decode str { + # rewrite "+" back to space + # protect \ from quoting another '\' + set str [string map [list + { } "\\" "\\\\"] $str] + + # prepare to process all %-escapes + regsub -all -- {%([A-Fa-f0-9][A-Fa-f0-9])} $str {\\u00\1} str + + # process \u unicode mapped chars + return [subst -novar -nocommand $str] + } + # routes: {path proc} proc ::httpd::router {name iroutes} { variable routes @@ -42,7 +55,7 @@ namespace eval ::httpd { lassign [split $path ?] path params foreach param [split $params &] { set value [join [lassign [split $param =] key] =] - dict lappend query $key $value + dict lappend query [uri-decode $key] [uri-decode $value] } } -- 2.45.2