[imp] Fix for addressbook javascript

Marcus I. Ryan marcus@riboflavin.net
Tue, 26 Mar 2002 21:21:09 -0600


As far as I can tell from my less then intimate relationship with RFC822
as long as the whole full name gets quoted, and any backslash and any
quote inside those quotes are escaped, it should be fine, so I escape
any existing backslashes and quotes, then throw quotes around it whether
it needs it or not.  Hope that's good enough, though it doesn't match
turba 100% (imap_rfc822_write_address doesn't add quotes if they are not
100% necessary)

horde/imp/templates/contacts/javascript.inc

--- javascript.orig     Tue Mar 26 20:55:50 2002
+++ javascript.inc      Tue Mar 26 21:16:24 2002
@@ -95,7 +95,9 @@
         var field   = null;

         fullname = fullname.substring(pos + 2, fullname.length);
-        address = fullname + " <" + address.substring(pos + 2,
address.length) + ">";
+       fullname = fullname.replace(/\\/g, '\\\\');
+        fullname = fullname.replace(/"/g, '\\"');
+        address = '"' + fullname + '" <' + address.substring(pos + 2,
address.length) + ">";
         if (f == "<?= _("To") ?>") {
             field = parent.opener.document.compose.to;
         } else if (f == "<?= _("Cc") ?>") {

Quoting Chuck Hagenbuch <chuck@horde.org>:

> Quoting "Marcus I. Ryan" <marcus@riboflavin.net>:
> 
> > FIX:
> > The patch below fixes two problems: (1) quotes full names and (2)
> > replaces any quotation marks in the name with '' instead, so the
> above
> > to line becomes:
> > 
> > "ryan, marcus" <marcus@riboflavin.net>, "yankovic, ''weird al''"
> > <weird_al@example.com>
> 
> How about doing proper RFC822 quoting instead? \", etc...
> 
> -chuck
> 
> --
> Charles Hagenbuch, <chuck@horde.org>
> "A dream which helps you to live your reality with dignity
>  and justice is a good dream." - Tariq Ramadan
> 
> -- 
> IMP mailing list: http://horde.org/imp/
> Archive: http://marc.theaimsgroup.com/?l=imp&r=1&w=2
> Frequently Asked Questions: http://horde.org/faq/
> To unsubscribe, mail: imp-unsubscribe@lists.horde.org
> 
> 


-- 
Marcus I. Ryan, marcus@riboflavin.net
-----------------------------------------------------------------------
 "Love is a snowmobile racing across the tundra and then suddenly it
 flips over, pinning you underneath.  At night, the ice weasels come."
                 -- Matt Groening
-----------------------------------------------------------------------