Fix for addressbook javascript

Marcus I. Ryan marcus@riboflavin.net
Mon, 25 Mar 2002 09:08:49 -0600


PROBLEM:
The current javascript does not quote the full name, so if I have a name
in my addressbook as "ryan, marcus" and another one as "yankovic, "weird
al"", then the addressbook, currently, returns a to line of:

ryan, marcus <marcus@riboflavin.net>, yankovic, "weird al"
<wierd_al@example.com>

The result is it tries to send to ryan, marcus@riboflavin.net, yankovic,
and wierd_al@example.com. 

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>

PATCH (horde/imp/templates/contacts/javascript.php):
--- javascript.orig     Mon Mar 25 08:41:31 2002
+++ javascript.inc      Mon Mar 25 09:03:09 2002
@@ -94,8 +94,10 @@
         var f       = address.substring(0, pos);
         var field   = null;

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


-- 
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
-----------------------------------------------------------------------