Hi,
Concerning the BUGFIX:
labels containing spaces were not encoded before being submitted, so we got a "http://mail... search=cat&cat=my
label&..." instead of "http://mail... search=cat&cat=my%20label&..."
I corrected every other unescaped string in fetch_box(), but left aside the Integers (obvious reason).
Concerning the improvement:
Parsing the http-responses was leaving some characters hard-coded. For details, see
GMailer::Connection.unescapeHTML(string)
For remarks, questions, or details: xcambar at gmail dot com
Here is the diff between gmailer-0.1.5 and gmailer-0.1.5-mod:
$ diff gmailer.rb gmailer_mod.rb
> #
> # return String
> # param string string
> # desc Unescapes properly Unicode escape characters
> #
> def unescapeHTML(string)
> string.gsub!(/(\\u(.{4}))/n) {
> match = $1.dup
> match = match[1..match.length]
> res=0
> for i in 0 .. match.reverse!.length-1
> res+= (match[i..i].hex)* 16**i
> end
> res.chr
> }
> string.gsub!(/&(.*?);/n) {
> match = $1.dup
> case match
> when /\Aamp\z/ni then '&'
> when /\Aquot\z/ni then '\"'
> when /\Agt\z/ni then '>'
> when /\Alt\z/ni then '<'
> when /\A#(\d+)\z/n then Integer($1).chr
> when /\A#x([0-9a-f]+)\z/ni then $1.hex.chr
> end
> }
> end
>
>
274a305
> unescapeHTML(x)
319c350
< q = "search=" + box.downcase + "&view=tl&start=" + pos.to_s
---
> q = "search=" + URI.escape(box.downcase) + "&view=tl&start=" +
pos.to_s
322c353
< q = "search=cat&cat=" + box.to_s + "&view=tl&start=" +
pos.to_s
---
> q = "search=cat&cat=" + URI.escape(box.to_s) + "&view=tl&start="
+ pos.to_s
327c358
< q += "&th=" + box[0].to_s
---
> q += "&th=" + URI.escape(box[0].to_s)
329c360
< q += "&msgs=" + box[i].to_s
---
> q += "&msgs=" + URI.escape(box[i].to_s)
332c363
< q += "&th=" + box.to_s
---
> q += "&th=" + URI.escape(box.to_s)
338c369
< q += "&th=" + box[0].to_s
---
> q += "&th=" + URI.escape(box[0].to_s)
340c371
< q += "&msgs=" + box[i].to_s
---
> q += "&msgs=" + URI.escape(box[i].to_s)
343c374
< q += "&th=" + box.to_s
---
> q += "&th=" + URI.escape(box.to_s)
349c380
< q += "&th=" + box[0].to_s
---
> q += "&th=" + URI.escape(box[0].to_s)
351c382
< q += "&msgs=" + box[i].to_s
---
> q += "&msgs=" + URI.escape(box[i].to_s)
354c385
< q += "&th=" + box.to_s
---
> q += "&th=" + URI.escape(box.to_s)
358c389
< q = "view=om&th=" + box.to_s
---
> q = "view=om&th=" + URI.escape(box.to_s) |