Issues

ZF-12119: Zend_Form_Element::filterName() removes characters which may be legal (e.g. periods, colons)

Description

According to W3C, form ID and NAME tokens must begin with a letter ([A-Za-z]) and may be followed by any number of letters, digits ([0-9]), hyphens ("-"), underscores ("_"), colons (":"), and periods ("."). - http://www.w3.org/TR/html4/types.html#type-cdata

Trying to create a form element with the name foo.bar makes it foobar - e.g.

require_once 'Zend/Form/Element/Hidden.php';

$foo = new Zend_Form_Element_Hidden(array('name' => 'foo.bar'));
echo $foo->getName(); // foobar

Comments

Hi Eddo, thanks for reporting!

The patch must include:

  • an update for {{Zend_Form::filterName()}} -- names must begin with a letter ([A-Za-z]) -- hyphens ("-"), underscores ("_"), colons (":") and periods (".") must be accepted
  • updates for the unit tests: -- {{Zend_Form_FormTest::testSetNameNormalizesValueToContainOnlyValidVariableCharacters()}} -- {{Zend_Form_FormTest::testArrayToWhichElementsBelongCanConsistOfValidVariableCharsOnly()}}
  • a new unit test for the first character in the name