lib/sup/source.rb in sup-1.0 vs lib/sup/source.rb in sup-1.1
- old
+ new
@@ -100,11 +100,11 @@
def valid? info
true
end
def synchronize &block
- @poll_lock.synchronize &block
+ @poll_lock.synchronize(&block)
end
def try_lock
acquired = @poll_lock.try_enter
if acquired
@@ -151,11 +151,11 @@
%w(subject from to cc bcc).each do |k|
v = header[k] or next
next unless Rfc2047.is_encoded? v
header[k] = begin
Rfc2047.decode_to $encoding, v
- rescue Errno::EINVAL, Iconv::InvalidEncoding, Iconv::IllegalSequence => e
+ rescue Errno::EINVAL, Iconv::InvalidEncoding, Iconv::IllegalSequence
#debug "warning: error decoding RFC 2047 header (#{e.class.name}): #{e.message}"
v
end
end
header
@@ -166,9 +166,15 @@
## convenience function
def parse_raw_email_header f; self.class.parse_raw_email_header f end
def Source.expand_filesystem_uri uri
uri.gsub "~", File.expand_path("~")
+ end
+
+ def Source.encode_path_for_uri path
+ path.gsub(Regexp.new("[#{Regexp.quote(URI_ENCODE_CHARS)}]")) { |c|
+ c.each_byte.map { |x| sprintf("%%%02X", x) }.join
+ }
end
end
## if you have a @labels instance variable, include this
## to serialize them nicely as an array, rather than as a