nntp::Session method decodeHeader (protected)
<instance of nntp::Session> decodeHeader nr headerString
Defined in packages/xowiki/tcl/nntp-procs.tcl
The value "nr" is just needed for the log messages.
- Parameters:
- nr (required)
- headerString (required)
- Testcases:
- No testcase defined.
Source code: :log notice "HEADER $headerString" set hdr "" foreach line [split $headerString \n] { if {[regexp {^(\S+):\s*(\S.*)$} $line . tag value]} { set value [string trim $value] set start 0 while {1} { set l [regexp -inline -indices -all -start $start {=[?]([^?]+)[?]([^?]+)[?](.*)[?]=} $value] if {[llength $l] == 0} { break } foreach {m charset encoding coded} $l { set charset [string range $value {*}$charset] set encoding [string range $value {*}$encoding] if {$encoding eq "B"} { set value [string replace $value {*}$m [ns_base64decode [string range $value {*}$coded]]] } else { ns_log warning "article $nr: ENCODED WORD" charset $charset encoding $encoding not implemented } set start [lindex $m 1] } } if {$start == 0} { :log notice "article $nr: plain <$value>" } else { :log notice "article $nr: decoded <$value>" } #if {[regexp {^=[?]([^?]+)[?]([^?]+)[?](.*)[?]=$} $value . charset encoding coded]} { # # Encoded word syntax (RFC 2047) # example: =?UTF-8?B?PyBCVUcgLSBUY2w5LjBiMyBMaW51eCAtIGNhbnZhcyBiaW5k?= # #ns_log notice "========= ENCODED WORD" charset $charset encoding $encoding coded $coded # if {$encoding eq "B"} { # set value [ns_base64decode $coded] # :log notice "article $nr: encoded word syntax: DECODED '$value'" # } else { # ns_log warning "article $nr: ENCODED WORD" charset $charset encoding $encoding not implemented # } # :log notice "article $nr: decoded <$value>" #} else { # :log notice "article $nr: plain <$value>" #} :log notice "article $nr: add header <[string tolower $tag]> <$value>" dict set hdr [string tolower $tag] $value } elseif {$line ne ""} { ns_log warning "article $nr: ignore HEADER line <$line>" } } return $hdrXQL Not present: Generic, PostgreSQL, Oracle