nette/nette — Issue #393: Nette\Forms\Form::MAX_LENGTH counts bytes, not chars
Author: Majkl578
Created: 2011-11-15 14:46:03+00:00
State: open

Nette doesn't treat line breaks as a single character and therefore the server-side validation for max length (and probably also for min length and length) is invalid for textareas.

Reproduce script:

```php
$form = new Nette\Forms\Form;
$form->addTextArea('foo')->addRule($form::MAX_LENGTH, 'too long', 10);
$form->addSubmit('submitter');
$form->fireEvents();
if ($form->isSubmitted()) {
echo 'Length: ', strlen($v = $form['foo']->getValue()), '
';
foreach(str_split($v) as $ch) {
echo '0x' . dechex(ord($ch)), ' ';
}
}

echo $form;
```