Brion Vibber wrote:
On 1/7/09 12:59 PM, Raimond Spekking wrote:
For a lot (all?) text input fields for reasons we have set a maxlength of 200 but some are set to 255.
Is there a special reason for 200? Or should we increase all to 255? Or reduce all to 200? I like consistency :)
The big trick is that these are generally for fields which have a database length limit of 255 *bytes*, which can be anywhere from 63 to 255 *characters* of UTF-8 text.
The 'maxlength' on the input field is enforced in Unicode *characters* by the browser.
I think the 200 is an arbitrary compromise to keep the in-browser limit from overflowing the field length in most European languages... but it's insufficient for non-Latin text.
I developed a JavaScript workaround some time ago to limit edit summaries to exactly 250 bytes. It's pretty hacky, but works:
http://en.wikipedia.org/wiki/User:Ilmari_Karonen/longeditsummary.js
I'd been thinking about adding something like it to MediaWiki itself, but kind of forgot about it. While doing so, we should also modify the edit UI so that, instead of silently truncating overlong summaries, it returns the user to the edit form with a warning message and the truncated summary, allowing the user to edit it before saving. That would let us safely raise the default maxlength to 255 even for users without JavaScript.
Of course, the same feature could and should be deployed for other length-limited summary fields, such as move summaries. (And BTW, why the heck is the UI element for those a textarea, anyway?)