Archive of RubyForge sup-devel mailing list
 help / color / mirror / Atom feed
* [sup-devel] [PATCH] Re: [sup-talk] Bug reading/writing contacts with \" in them
       [not found] <1295845756-sup-308@pruts.nl>
@ 2011-01-24 18:20 ` Michael Stapelberg
  2011-06-20 22:45   ` Hamish Downer
  0 siblings, 1 reply; 2+ messages in thread
From: Michael Stapelberg @ 2011-01-24 18:20 UTC (permalink / raw)
  To: sup-devel; +Cc: sup-talk

[-- Attachment #1: Type: text/plain, Size: 1083 bytes --]

Hi Ico,

Excerpts from Ico's message of 2011-01-24 06:20:47 +0100:
> The problem occurs when contacts have a certain combination of backslashes and
> quotes in them. I 'imported' my mutt aliases with a simple script converting
> the format (too bad it is *almost* the same but not quite), and one of the
> contacts looked like this:
> 
>   somename: \"Some, Name\" <somename@somedomain.com>
As discussed on IRC, I’ve made the following findings:

 • Some combinations of email addresses (phrase + addr-spec in RFC822
   terminology) need to be escaped, for example when they contain a comma or a
   quote.
 • This escaping happens in Person#full_address by using @name.inspect
 • Person#full_address also is used when saving contacts back to contacts.txt
 • Person#initialize partly strips the quotes (line 10/11), but does not handle
   backslashes.

Attached is a patch which fixes the issue. Input like "Rob, Post\" will first
be turned into "Rob, Post\\" when initially escaping, but will then stay "Rob,
Post\\" (no more exploding backslashes).

Best regards,
Michael

[-- Attachment #2: 0001-Bugfix-Un-escape-slashes-when-initializing-a-new-Per.patch --]
[-- Type: application/octet-stream, Size: 798 bytes --]

From 318d1a4f88a75776123471a665807923c8463dd0 Mon Sep 17 00:00:00 2001
From: Michael Stapelberg <michael@stapelberg.de>
Date: Mon, 24 Jan 2011 19:18:57 +0100
Subject: [PATCH] Bugfix: Un-escape slashes when initializing a new Person

In Person#full_address, we add slashes by using @name.inspect, so we need to
take care of them here.
---
 lib/sup/person.rb |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/lib/sup/person.rb b/lib/sup/person.rb
index 28887b3..45660c0 100644
--- a/lib/sup/person.rb
+++ b/lib/sup/person.rb
@@ -9,6 +9,7 @@ class Person
     @name = if name
       name = name.strip.gsub(/\s+/, " ")
       name =~ /^(['"]\s*)(.*?)(\s*["'])$/ ? $2 : name
+      name.gsub('\\\\', '\\')
     end
 
     @email = email.strip.gsub(/\s+/, " ").downcase
-- 
1.7.1


[-- Attachment #3: Type: text/plain, Size: 143 bytes --]

_______________________________________________
Sup-devel mailing list
Sup-devel@rubyforge.org
http://rubyforge.org/mailman/listinfo/sup-devel

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [sup-devel] [PATCH] Re: [sup-talk] Bug reading/writing contacts with \" in them
  2011-01-24 18:20 ` [sup-devel] [PATCH] Re: [sup-talk] Bug reading/writing contacts with \" in them Michael Stapelberg
@ 2011-06-20 22:45   ` Hamish Downer
  0 siblings, 0 replies; 2+ messages in thread
From: Hamish Downer @ 2011-06-20 22:45 UTC (permalink / raw)
  To: sup-devel

Excerpts from Michael Stapelberg's message of Mon Jan 24 18:20:13 +0000 2011:
> Excerpts from Ico's message of 2011-01-24 06:20:47 +0100:
> > The problem occurs when contacts have a certain combination of backslashes and
> > quotes in them. 
> > 
> >   somename: \"Some, Name\" <somename@somedomain.com>
> 
> Attached is a patch which fixes the issue. Input like "Rob, Post\" will first
> be turned into "Rob, Post\\" when initially escaping, but will then stay "Rob,
> Post\\" (no more exploding backslashes).

Another patch that slipped through the net. Now applied to next.

Hamish

-- 
Hamish Downer <hamish@foobacca.co.uk>

Web: http://www.foobacca.co.uk/
GPG: B7C48416
_______________________________________________
Sup-devel mailing list
Sup-devel@rubyforge.org
http://rubyforge.org/mailman/listinfo/sup-devel


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2011-06-20 22:45 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <1295845756-sup-308@pruts.nl>
2011-01-24 18:20 ` [sup-devel] [PATCH] Re: [sup-talk] Bug reading/writing contacts with \" in them Michael Stapelberg
2011-06-20 22:45   ` Hamish Downer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox