From aab6532fbf7681bd90383401d404a76f0c3bc5e3 Mon Sep 17 00:00:00 2001 From: lnu Date: Tue, 5 Apr 2005 16:35:35 +0000 Subject: git-svn-id: svn+ssh://svn.gna.org/svn/feed2imap/trunk/feed2imap@14 f70e237a-67f3-0310-a06c-d2b8a7116972 --- lib/feed2imap/channel.rb | 26 +++++++++++++------------- lib/feed2imap/feed2imap.rb | 1 + lib/feed2imap/imap.rb | 4 +++- lib/feed2imap/textconverters.rb | 15 ++++++++++++++- 4 files changed, 31 insertions(+), 15 deletions(-) (limited to 'lib/feed2imap') diff --git a/lib/feed2imap/channel.rb b/lib/feed2imap/channel.rb index a9b4499..d59b47b 100644 --- a/lib/feed2imap/channel.rb +++ b/lib/feed2imap/channel.rb @@ -196,19 +196,19 @@ class Item def to_text s = "" s += "Channel: " - s += @channel.title + ' ' if @channel.title - s += "<#{@channel.link}>" if @channel.link + s += @channel.title.toISO_8859_1('utf-8') + ' ' if @channel.title + s += "<#{@channel.link.toISO_8859_1('utf-8')}>" if @channel.link s += "\n" s += "Item: " - s += @title + ' ' if @title - s += "<#{@link}>" if @link + s += @title.toISO_8859_1('utf-8') + ' ' if @title + s += "<#{@link.toISO_8859_1('utf-8')}>" if @link s += "\n" - s += "\nDate: #{@date.to_s}" if @date # TODO improve date rendering ? - s += "\nAuthor: #{@creator}" if @creator - s += "\nSubject: #{@subject}" if @subject - s += "\nCategory: #{@category}" if @category + s += "\nDate: #{@date.to_s.toISO_8859_1('utf-8')}" if @date # TODO improve date rendering ? + s += "\nAuthor: #{@creator.toISO_8859_1('utf-8')}" if @creator + s += "\nSubject: #{@subject.toISO_8859_1('utf-8')}" if @subject + s += "\nCategory: #{@category.toISO_8859_1('utf-8')}" if @category s += "\n\n" - s += "#{@content.html2text}" if @content + s += "#{@content.html2text.toISO_8859_1('utf-8')}" if @content s end @@ -249,14 +249,14 @@ class Item message.header['X-F2IStatus'] = "Updated" if @cacheditem.updated # TODO encode in ISO ? if @title - message.header['Subject'] = @title + message.header['Subject'] = @title.toISO_8859_1('utf-8') elsif @date - message.header['Subject'] = @date.to_s + message.header['Subject'] = @date.to_s.toISO_8859_1('utf-8') elsif @link - message.header['Subject'] = @link + message.header['Subject'] = @link.toISO_8859_1('utf-8') end textpart = RMail::Message::new - textpart.header['Content-Type'] = 'text/plain; charset=UTF-8; format=flowed' + textpart.header['Content-Type'] = 'text/plain; charset=iso-8859-1; format=flowed' textpart.header['Content-Transfer-Encoding'] = '7bit' textpart.body = to_text htmlpart = RMail::Message::new diff --git a/lib/feed2imap/feed2imap.rb b/lib/feed2imap/feed2imap.rb index 9896a3c..daee87d 100644 --- a/lib/feed2imap/feed2imap.rb +++ b/lib/feed2imap/feed2imap.rb @@ -129,6 +129,7 @@ class Feed2Imap end rescue @logger.fatal("Exception caught while uploading mail to #{f.folder}: #{$!}") + puts $!.backtrace next end begin diff --git a/lib/feed2imap/imap.rb b/lib/feed2imap/imap.rb index 70a0aa0..301b95c 100644 --- a/lib/feed2imap/imap.rb +++ b/lib/feed2imap/imap.rb @@ -99,13 +99,15 @@ class ImapAccount def updatemail(folder, mail, idx) @connection.select(folder) searchres = @connection.search(['HEADER', 'X-CacheIndex', "-#{idx}-"]) + flags = nil if searchres.length == 1 + flags = @connection.fetch(searchres[0], 'FLAGS')[0].attr['FLAGS'] @connection.store(searchres[0], "+FLAGS", [:Deleted]) @connection.expunge elsif searchres.length != 0 raise "Search returned multiple results !!" end - putmail(folder, mail) + @connection.append(folder, mail, flags) end def to_s diff --git a/lib/feed2imap/textconverters.rb b/lib/feed2imap/textconverters.rb index ba49193..b28c211 100644 --- a/lib/feed2imap/textconverters.rb +++ b/lib/feed2imap/textconverters.rb @@ -61,10 +61,23 @@ class String return self.gsub!(/\A\s*/m, '').gsub!(/\s*\Z/m,'') end + # Convert a text in inputenc to a text in ISO-8859-1 + def toISO_8859_1(inputenc) + if inputenc.downcase == 'utf-8' + begin + return self.unpack('U*').pack('C*') + rescue + return self + end + else + return self + end + end + # Convert a text in inputenc to a text in UTF8 # must take care of wrong input locales def toUTF8(inputenc) - if inputenc.downcase! != 'utf-8' + if inputenc.downcase != 'utf-8' # it is said it is not UTF-8. Ensure it is REALLY not UTF-8 begin if self.unpack('U*').pack('U*') == self -- cgit v1.2.3-70-g09d2 lass='insertions'>+1 2014-04-19platform: Auto-detect local platform fileJason A. Donenfeld2-3/+3 2014-04-19platform: Allow custom platform file before installJason A. Donenfeld2-3/+5 2014-04-18reencrypt: cleaner temp file declarationJason A. Donenfeld1-4/+4 2014-04-18Remove unneeded semicolon.Jason A. Donenfeld1-14/+14 2014-04-18Check sneaky paths.Jason A. Donenfeld1-0/+15 2014-04-18Pruning: turns out rmdir does it for us with -p.Jason A. Donenfeld1-9/+3 2014-04-18Abstract remove empty directories into function.Jason A. Donenfeld1-14/+11 2014-04-18Remember to prune empty folders.Jason A. Donenfeld1-0/+8 2014-04-18init: allow deinitializationJason A. Donenfeld2-2/+18 2014-04-18bash-completion: filter dot files from resultsJason A. Donenfeld1-3/+8 2014-04-18reencrypt: remove option, do automaticallyJason A. Donenfeld5-39/+25 2014-04-18reencryption: add to completion filesJason A. Donenfeld3-1/+5 2014-04-18Specify variable gpg.Jason A. Donenfeld1-1/+1 2014-04-18style: don't escape new line on &&Jason A. Donenfeld1-2/+2 2014-04-18reencryption: remove temporary file on failureJason A. Donenfeld1-1/+1 2014-04-18reencryption: only reencrypt files when requiredJason A. Donenfeld2-16/+37 2014-04-17cp: typo as cvJason A. Donenfeld1-1/+1 2014-04-17bash: gpg_id is localJason A. Donenfeld1-0/+1 2014-04-17move/copy: always reencrypt passwords at destinationJason A. Donenfeld5-25/+56 2014-04-17makefile: allow platform files with gnu sedJason A. Donenfeld1-7/+8 2014-04-17mv: Add pass mv/rename supportJason A. Donenfeld5-3/+78 2014-04-17revelation2pass: add plain XML importJavali1-11/+15 2014-04-17platform: add cygwin supportJason A. Donenfeld2-1/+17