Forums / Bug Reports / [Done v1.3.8] Apostrophes in customer emails results in MySQL errors

[Done v1.3.8] Apostrophes in customer emails results in MySQL errors

Locked

Views: 1,968

Results 1 to 3 of 3
This thread is locked. New replies are disabled.
20 Apr 2007, 3:50 PM
#1
rmullaney77 avatar

rmullaney77

New Zenner

Join Date:
Mar 2007
Location:
Lakeland, FL, US
Posts:
44
Plugin Contributions:
1

[Done v1.3.8] Apostrophes in customer emails results in MySQL errors

ZC Version:
1.3.7

Filename:
/admin/orders.php

Problem:
When updating orders (status), a MySQL error is raised when choosing "notify customer" if the email addresses contains an apostrophy.

Solution:
Properly escape the email address in the resulting sql query used for the customer notification.

Comments:
An apostrophe, though uncommon, is a valid character in an email address. All queries that contain items that may have such characters should always be escaped before the query is executed. Technically, ALL queries should be escaped before execution just to be safe.

24 Apr 2007, 4:47 AM
#2
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,513
Plugin Contributions:
176

Re: [Done v1.3.8] Apostrophes in customer emails results in MySQL errors

The exact SQL error would be a great help in tracking this down.

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

24 Apr 2007, 6:10 AM
#3
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,513
Plugin Contributions:
176

Re: [Done v1.3.8] Apostrophes in customer emails results in MySQL errors

If it's the message I think you're getting, this should fix it:

/includes/functions/functions_email.php

around line 110 you'll find this://determine customer's email preference type: HTML or TEXT-ONLY (HTML assumed if not specified) $customers_email_format_read = $db->Execute("select customers_email_format from " . TABLE_CUSTOMERS . " where customers_email_address= '" . $to_email_address . "'");Change it to this:```
//determine customer's email preference type: HTML or TEXT-ONLY (HTML assumed if not specified)
$customers_email_format_read = $db->Execute("select customers_email_format from " . TABLE_CUSTOMERS . " where customers_email_address= '" . [B]zen_db_input([/B]$to_email_address[B])[/B] . "'");

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.