[dev] [PATCH] Little bug in imp/contacts.php javascript
Etienne Goyer
etienne.goyer at linuxquebec.com
Tue Dec 16 07:46:19 PST 2003
On Mon, Dec 15, 2003 at 11:05:27PM -0500, Chuck Hagenbuch wrote:
> Quoting Etienne Goyer <etienne.goyer at linuxquebec.com>:
>
> > In imp/contacts.php, when selecting a contact and clicking a localized
> > "To", Cc" or "Bcc" and this one contain 8 bits character, it does not
> > work. I don't know Javascript enough to explain why but the following
> > two trivials patch fixed it for me and I can't see anything wrong with
> > them. They basically change the content of a Javascript variable with
> > which the user does not interact.
>
> First of all, there's no reason to escape into PHP in order to echo a constant
> string.
>
> jsVar = '<?php echo "To" ?>';
>
> is just a really really painful way to write:
>
> jsVar = 'To';
Ok, I admit that is pretty brain-dead. I did not gave it much tought.
> Also, I'm not convinced this is necessary. Try doing <?php echo
> addslashes(_("To")) and see if that works for you.
But why use a translation in the first place ? It's just Javascript
variables content, and it's never displayed to the user. We could do it
entirely without escaping to PHP.
Patch included.
--
Etienne Goyer Linux Québec Technologies Inc.
http://www.LinuxQuebec.com etienne.goyer at linuxquebec.com
-------------- next part --------------
--- templates/contacts/contacts.inc.orig Mon Dec 15 14:42:47 2003
+++ templates/contacts/contacts.inc Tue Dec 16 10:44:19 2003
@@ -36,7 +36,7 @@
<td>
<table border="0" width="100%" cellpadding="0">
<tr>
- <td width="45%"><select name="search_results" multiple="multiple" size="10" width="200" onchange="document.contacts.search_results[0].selected=false" ondblclick="addAddress('<?php echo _("To") ?>')">
+ <td width="45%"><select name="search_results" multiple="multiple" size="10" width="200" onchange="document.contacts.search_results[0].selected=false" ondblclick="addAddress('To')">
<option value=""><?php echo _("* Please select address(es) *") ?></option>
<?php foreach ($addresses as $addr): ?>
<?php if ($display == 'email'): ?>
@@ -48,9 +48,9 @@
</select>
</td>
<td width="10%">
- <input type="button" class="button" style="width:60px" onclick="addAddress('<?php echo _("To") ?>');" value="<?php echo _("To") . " >>" ?>" /><br /> <br />
- <input type="button" class="button" style="width:60px" onclick="addAddress('<?php echo _("Cc") ?>');" value="<?php echo _("Cc") . " >>" ?>" /><br /> <br />
- <input type="button" class="button" style="width:60px" onclick="addAddress('<?php echo _("Bcc") ?>');" value="<?php echo _("Bcc") . " >>" ?>" /></td>
+ <input type="button" class="button" style="width:60px" onclick="addAddress('To');" value="<?php echo _("To") . " >>" ?>" /><br /> <br />
+ <input type="button" class="button" style="width:60px" onclick="addAddress('Cc');" value="<?php echo _("Cc") . " >>" ?>" /><br /> <br />
+ <input type="button" class="button" style="width:60px" onclick="addAddress('Bcc');" value="<?php echo _("Bcc") . " >>" ?>" /></td>
<td width="45%" colspan="2">
<select name="selected_addresses" multiple="multiple" size="10" width="200" onchange="document.contacts.selected_addresses[0].selected=false">
<option value=""><?php echo _("* Add these by clicking OK *") ?></option>
-------------- next part --------------
--- templates/contacts/javascript.inc.orig Mon Dec 15 14:43:36 2003
+++ templates/contacts/javascript.inc Tue Dec 16 10:41:26 2003
@@ -102,11 +102,11 @@
} else {
address = '"' + fullname + '" <' + address.substring(pos + 2, address.length) + ">";
}
- if (f == "<?php echo _("To") ?>") {
+ if (f == "To") {
field = parent.opener.document.compose.to;
- } else if (f == "<?php echo _("Cc") ?>") {
+ } else if (f == "Cc") {
field = parent.opener.document.compose.cc;
- } else if (f == "<?php echo _("Bcc") ?>") {
+ } else if (f == "Bcc") {
field = parent.opener.document.compose.bcc;
} else {
continue;
More information about the dev
mailing list