Skip to content
Tcl Source Code View Ticket
Login

View Ticket

2016-09-24
19:00 • New ticket [838e99a76d] treat application/xml as text. artifact: 09db90cdff user: gahr
2007-06-13
14:52 • Closed ticket [1733261fff]: http::Event encoding (RSS/UTF-8) plus 6 other ch... artifact: 59f8e1f27f user: rniva
02:13 • Pending ticket [1733261fff]. artifact: 864b00ee71 user: hobbs
2007-06-11
14:54 • Open ticket [1733261fff]. artifact: f3d1f05b7c user: rniva
03:58 • Pending ticket [1733261fff]. artifact: 476e574415 user: hobbs
2007-06-08
16:42 • Ticket [1733261fff]: 4 changes artifact: a184b6ddec user: dkf
15:21 • Ticket [1733261fff]: 4 changes artifact: b4b8839682 user: rniva
15:07 • Ticket [1733261fff]: 4 changes artifact: 1f7b444358 user: dkf
07:56 • New ticket [1733261fff]. artifact: 8fbf12d98f user: rniva

http::Event encoding (RSS/UTF-8)

Closed / Wont Fix1733261fffffffffffffffffffffffffffffffffCreated 19 years agoUpdated 19 years ago
Descriptionplain2007-06-08 07:56:46
This snippet of code from http::Event assumes that all non-text content is binary:

if {$state(-binary) || ![string match -nocase text* $state(type)]
   || [string match *gzip* $state(coding)]
   || [string match *compress* $state(coding)]} {
# Turn off conversions for non-text data
fconfigure $s -translation binary

We are using the http package to download RSS feeds in UTF-8 encoding.
Mimetype: application/rss+xml

And the client is running system encoding UTF-8.

This causes the RSS feed to have double UTF-8 encoded strings.

We did a temporary fix to our client while we wait for a bugfix:

if {$state(-binary) || (![string match -nocase text* $state(type)] && ![string match -nocase *xml* $state(type)])
dkfplain2007-06-08 15:07:31
Logged In: YES 
user_id=79902
Originator: NO

set decoded [encoding convertfrom utf-8 [http::data $token]]
rnivaplain2007-06-08 15:21:16
Logged In: YES 
user_id=729740
Originator: YES

>set decoded [encoding convertfrom utf-8 [http::data $token]]

Yes, this is what I first thought of, but I don't think we can assume that every RSS feed is in UTF-8?
Besides there are other application/*+xml types that should also be handled in http::Event.
dkfplain2007-06-08 16:42:27
Logged In: YES 
user_id=79902
Originator: NO

Well, when you're not certain what is going on with the encoding you *really* want the data in binary form and then (after picking apart WTF is going on) using [encoding convertfrom]. Like that you stand a chance of actually getting to a meeting of minds with the webserver (assuming that's not fundamentally confused, which happens unfortunately often...)
hobbsplain2007-06-11 03:58:46
Logged In: YES 
user_id=72656
Originator: NO

Doesn't the 'charset' field of the state array deal with this for you?  Convert to the named charset when present.
rnivaplain2007-06-11 14:54:01
Logged In: YES 
user_id=729740
Originator: YES

Probably, but isn't that a "private" variable?
There should, at the very least, exist a proc for returning the content-type so you don't have to muck around with variables that may change in a future version.
hobbsplain2007-06-13 02:13:46
Logged In: YES 
user_id=72656
Originator: NO

The charset key of the state variable is a documented key, along with how to access it, in the http docs.
rnivaplain2007-06-13 14:52:38
Logged In: YES 
user_id=729740
Originator: YES

I bow down to the wisdom of the great elders of tickle.
Thanks for prompt responses and patience with my ignorance.
Log in (anonymous is fine) to add a comment.