summaryrefslogtreecommitdiff
path: root/lib/feed2imap/config.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/feed2imap/config.rb')
-rw-r--r--lib/feed2imap/config.rb18
1 files changed, 17 insertions, 1 deletions
diff --git a/lib/feed2imap/config.rb b/lib/feed2imap/config.rb
index 5e339c7..6c3654b 100644
--- a/lib/feed2imap/config.rb
+++ b/lib/feed2imap/config.rb
@@ -109,7 +109,8 @@ class ConfigFeed
@name = f['name']
@url = f['url']
@url.sub!(/^feed:/, '') if @url =~ /^feed:/
- @imapaccount, @folder = imapaccount, folder
+ @imapaccount = imapaccount
+ @folder = encode_utf7 folder
@freq = f['min-frequency']
@always_new = false
@@ -136,4 +137,19 @@ class ConfigFeed
return true if @freq.nil?
return (lastcheck + @freq * 3600) < Time::now
end
+
+ def encode_utf7(s)
+ if "foo".respond_to?(:force_encoding)
+ return Net::IMAP::encode_utf7 s
+ else
+ # this is a copy of the Net::IMAP::encode_utf7 w/o the force_encoding
+ return s.gsub(/(&)|([^\x20-\x7e]+)/u) {
+ if $1
+ "&-"
+ else
+ base64 = [$&.unpack("U*").pack("n*")].pack("m")
+ "&" + base64.delete("=\n").tr("/", ",") + "-"
+ end }
+ end
+ end
end