~aleteoryx/tclfeed-bsky

dd19de9860747c84b40cfbce04302383ae759d40 — Aleteoryx 29 days ago 10a4e0f
fixes
4 files changed, 26 insertions(+), 5 deletions(-)

M bin/up.tcl
M lib/atpagent.tcl
A plume.png
M src/httpd.tcl
M bin/up.tcl => bin/up.tcl +9 -1
@@ 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
}

M lib/atpagent.tcl => lib/atpagent.tcl +3 -3
@@ 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

A plume.png => plume.png +0 -0
M src/httpd.tcl => src/httpd.tcl +14 -1
@@ 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]
      }
    }