Geekzone: technology news, blogs, forums
Guest
Welcome Guest.
You haven't logged in yet. If you don't have an account you can register now.


MurrayM

2502 posts

Uber Geek
+1 received by user: 742

ID Verified
Trusted
Lifetime subscriber

#116039 16-Apr-2013 16:05
Send private message

Can anyone tell me what the maximum length of an HTML form field "name" attribute is?

What I've discovered is that this form field is ok:

<input name="1234567890123456789012345678901234567890123456789012345678901234" type="text" size="30" maxlength="30" value="">

But that this isn't ok:

<input name="12345678901234567890123456789012345678901234567890123456789012345" type="text" size="30" maxlength="30" value="">

The difference is that the first example has a Name attribute that is 64 characters long and the second has a Name attribute that is 65 characters long.

On a web server that I use that's running Apache 2.2.3 the first works and the second fails, so it looks like the maximum length you can have is 64 characters.  But on another web server that I use that is running Apache 2.2.4 both examples work ok.

I've tried looking on the Apache site to see if this is specified anywhere but I'm not familiar with the site and I can't seem to find any documentation about this.  Can anyone comment?

Filter this topic showing only the reply marked as answer Create new topic
ubergeeknz
3344 posts

Uber Geek
+1 received by user: 1041

Trusted
Vocus

  #800292 16-Apr-2013 16:09
Send private message

Could it be that the POST data is exceeding some limit, rather than anything to do with the form itself?

edit: it seems to be related to some security packages, eg. Suhosin, which makes sense.  Why do you want to use a name longer than 64 chars anyway?



MurrayM

2502 posts

Uber Geek
+1 received by user: 742

ID Verified
Trusted
Lifetime subscriber

  #800298 16-Apr-2013 16:20
Send private message

It's a bit difficult to explain why I'm using such long names, but it has to do with product id's that are randomly generated so that they are unique and they're quite long hex values.

I'm thinking that I may need to do things a different way to get around this limit.

But I was just interested in if anyone knew about a particular limit.

MurrayM

2502 posts

Uber Geek
+1 received by user: 742

ID Verified
Trusted
Lifetime subscriber

  #800306 16-Apr-2013 16:23
Send private message

BTW the server having the problem does indeed run Suhosin. Thanks for pointing me in this direction, that explains things!



mattwnz
20515 posts

Uber Geek
+1 received by user: 4795


  #800309 16-Apr-2013 16:27
Send private message

For security , it is probably better it has the limit in place , than doesn't.

MurrayM

2502 posts

Uber Geek
+1 received by user: 742

ID Verified
Trusted
Lifetime subscriber

  #800314 16-Apr-2013 16:29
Send private message

mattwnz: For security , it is probably better it has the limit in place , than doesn't.


Yup, I'll just have to put the product ID's in hidden fields rather than passing them across in the Name attribute.

heapsort
250 posts

Master Geek
+1 received by user: 82

Lifetime subscriber

  #800339 16-Apr-2013 17:02
Send private message

You mentioned they are long hex values, so at 4 bits per character a 64-character value can handle 256 bits.

If you wanted to stick with the current method of encoding a long unique value in the name and need more than 256 bits (although even 128-bit MD5 and 80-bit SHA1 is enough to practically guarantee uniqueness) but don't need a lot more than that, then you could encode the name with base64 instead of hex. At 6 bits per character, you'd get 384 bits from a 64-character value.

 
 
 

Stream your favourite shows now on Apple TV (affiliate link).
MurrayM

2502 posts

Uber Geek
+1 received by user: 742

ID Verified
Trusted
Lifetime subscriber

  #800348 16-Apr-2013 17:11
Send private message

Thanks for that suggestion. The names I were using were actually longer than that because I was joining two product ID's together (actually a Product ID and a Variation ID) and some other stuff.

I've got it sorted now by using some hidden fields. I guess the lesson is not to put actual data in the Name attribute!

Filter this topic showing only the reply marked as answer Create new topic








Geekzone Live »

Try automatic live updates from Geekzone directly in your browser, without refreshing the page, with Geekzone Live now.



Are you subscribed to our RSS feed? You can download the latest headlines and summaries from our stories directly to your computer or smartphone by using a feed reader.