Closed (won't fix)
Project:
Drupal core
Version:
5.x-dev
Component:
forms system
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
21 Dec 2006 at 05:59 UTC
Updated:
3 Jan 2007 at 19:45 UTC
Jump to comment: Most recent file
Comments
Comment #1
ChrisKennedy commentedAttached patch implements #maxlength validation.
To test, remove the maxlength attribute from the subject field for comments using the following jquery: '$("#edit-subject").attr("maxlength", "")' then submit a comment with a subject of more than 64 characters.
Comment #2
ChrisKennedy commentedUpdated to use drupal_strlen() per chx's suggestion.
Comment #3
chx commentedThis is a very fine idea. The usage of !$name is OK.
Comment #4
ChrisKennedy commentedUpdated not to assume that #title has been set per chx/Heine's suggestion.
Comment #5
dries commentedCommitted to CVS HEAD.
Comment #6
yched commentedthis implementation treats '#maxlength' => '' as maxlength = 0 and rejects any entry
Attached patch adds an is_numeric check.
Comment #7
ChrisKennedy commentedFair enough.
Comment #8
chx commentedHuh? #maxlength is not user data, I do not see the need. If you want any check then
isset( maxlength ) && maxlengthComment #9
ChrisKennedy commentedI would prefer not to do a lazy evaluation of maxlength's boolean value and maintain the ability to set it to zero. It is handy to be able to set #maxlength to 0 and have this be enforced - for example it would be a great way to create a trap for automated form spambots (create a hidden URL form element with maxlength=0).
I'm mostly ambivalent towards the is_numeric change. On the one hand #maxlength should be unset() programmatically rather than setting it to an empty string, but on the other hand it is understandable for a programmer to not expect that '' would result in the test always failing.
Comment #10
chx commentedOK then, if 0 is a desired setting then this is a won't fix: the motto is "we do not babysit broken code". Setting a numeric setting to an empty string is broken code.
Comment #11
yched commentedNot babysitting suits me fine.
But then maybe this should be mentioned in the "4.7 to 5.0 module update" page, since this breaks code that was working OK in 4.7.
I'm re-opening the issue for this.
Comment #12
ChrisKennedy commentedNo need to re-open this issue for a separate task, just post a comment to the 5.x module version page (or edit it if you have access).
Comment #13
yched commentedDone - thanks
Comment #14
ChrisKennedy commentedAfter looking at yched's example I realized that it does make sense to support '', because this is used to initialize variables when seeking E_ALL compliance. I think my "E_ALL compliance during installation" patch does this also. Since 0 is a valid setting it can't be used to initialize maxlength to a neutral value, thus the is_numeric() check is worthwhile (or !== '').
Comment #15
RobRoy commentedBut, shouldn't we just be initializing #maxlength to NULL?
Comment #16
chx commented#maxlength is initialized to 128 in system_elements. What are we talking about...?