9 replies [Last post]
Troy Dalmasso's picture
Offline
Joined: 08/06/2008
Juice: 106
Was this information Helpful?

I get this error on the Ship Packages page after hitting the Review Shipment button. A 32 character limit seems too small to me and I'm thinking this must be a bug in the system?

Does anyone have any input on this topic?

-=-
Troy Dalmasso

Lyle's picture
Offline
AdministratoreLiTe!
Joined: 08/07/2007
Juice: 6846
Re: ERROR "E-mail cannot be longer than 32 characters..."

I agree that 32 characters is too small, but I don't know where the limit is coming from.

TR
TR's picture
Offline
Bug FinderFAQ ModeratorGetting busy with the Ubercode.
Joined: 11/05/2007
Juice: 3424
Lyle wrote:I agree that 32
Lyle wrote:

I agree that 32 characters is too small, but I don't know where the limit is coming from.

Hi Lyle,

Seems the problem is that the function uc_textfield() defaults to a #maxlength of 32. So the forms API validation generates that error for any textfield that doesn't override the default #maxlength.

Two ways to fix this. Either 1) change the #maxlength default in the uc_textfield() function declaration, or 2) explicitly pass uc_textfield() a #maxlength when defining an e-mail input field on a form. The first just defers the problem, since then e-mail addresses of 64 (or 128, or whatever the new limit is) characters will still fail. The second requires reviewing *all* uses of uc_textfield() in Ubercart to ensure the default #maxlength=32 is appropriate for each use (and changing the call to pass a more appropriate #maxlength if not...). I'm sure this implicit limit affects other inputs, or at least other uses of the e-mail field, so I think it really does warrant a review of all the code to see if the same problem exists elsewhere.

<tr>.
Troy Dalmasso's picture
Offline
Joined: 08/06/2008
Juice: 106
Thanks, TR! I cross posted,

Thanks, TR!

I cross posted, here and the Support forum, because I didn't know the cause of the issue. I will post a new comment there directing others to this thread. There is already one other user reporting the issue using google checkout. Mine is occurring using the UPS module. It should be noted that I get the issue when choosing "UPS" but not when choosing "Ship Manually" in the "Shipping method:" menu.

Thanks for your reply. I'll keep an eye on this bug.

Troy Dalmasso's picture
Offline
Joined: 08/06/2008
Juice: 106
Any takers?

I have a hard time believing I'm the only one getting this error when trying to use Ubercart.

AttachmentSize
Picture 11.png 74.37 KB
Bao Ha's picture
Offline
Joined: 09/26/2009
Juice: 12
Re: ERROR "E-mail cannot be longer than 32 characters..."

I saw this yesterday when trying to update the shipping.

Following is the patch that makes it go away, temporarily:

--- uc_shipping.module.orig 2010-02-02 18:20:17.000000000 -0800
+++ uc_shipping.module 2010-02-02 18:21:41.000000000 -0800
@@ -637,7 +637,7 @@

$order_form = uc_order_pane_ship_to('edit-form', $order);
$form['destination'] = $order_form['ship_to'];
- $form['destination']['delivery_email'] = uc_textfield(uc_get_field_name('email'), $order->primary_email, FALSE);
+ $form['destination']['delivery_email'] = uc_textfield(uc_get_field_name('email'), $order->primary_email, FALSE, NULL, 64);
$form['destination']['delivery_email']['#weight'] = -1;
$form['destination']['#title'] = t('Destination Address');
$form['destination']['#collapsible'] = TRUE;

Kiwigrower's picture
Offline
Joined: 01/16/2010
Juice: 32
Will this code get into the next release?

Thanks Bao Ha,

This worked for me. Did the others above in this thread do something different or figure it out themselves? What is the standard way to fix this?

oliver coleman's picture
Offline
Bug Finder
Joined: 01/09/2008
Juice: 212
Max email length and store address, too

Two things:

It looks like the maximum email address length is 254 characters, according to this fairly thorough-looking analysis: http://www.dominicsayers.com/isemail/

The maximum length of the store email address also needs to be fixed on this page, for now you can change line 619:
$form['origin']['pickup_email'] = uc_textfield(uc_get_field_name('email'), variable_get('uc_store_email', NULL), FALSE);
to
$form['origin']['pickup_email'] = uc_textfield(uc_get_field_name('email'), variable_get('uc_store_email', NULL), FALSE, NULL, 254);

(or replace 254 with your preferred maximum length. Smiling)

MikeMcCormac's picture
Offline
Joined: 04/02/2010
Juice: 6
Hi Thanks for above fix - it

Hi

Thanks for above fix - it worked just fine.

If it helps anybody else, the fix above just fixes the 'origin' email address.

You also need to go down to line 640 to fix the destination email address and substitute that with:

$form['destination']['delivery_email'] = uc_textfield(uc_get_field_name('email'), $order->primary_email, FALSE, NULL, 254);

Of course assuming you're making the limit 254 characters as above!

Mike

scottastic's picture
Offline
Joined: 07/01/2010
Juice: 31
Re: Hi Thanks for above fix - it

Thanks! The first bit of code didn't seem to change anything, but the line on 640 I altered and now I could save the shipment finally.

This really should be put into the next Ubercart update... 32 characters is much too short for an email and really is a bug.