Issues

ZF-12050: formSelect optgroup syntax broken

Issue Type: Bug Created: 2012-02-09T22:38:59.000+0000 Last Updated: 2012-02-25T17:27:27.000+0000 Status: Open Fix version(s): Reporter: Arno Schäfer (arnoschaefer) Assignee: Matthew Weier O'Phinney (matthew) Tags: - Zend_View

  • state:need-feedback
  • zf-crteam-review

Related issues: Attachments: - ZF-12050.patch

Description

When creating optgroups, the label is also used as part of the id:

<pre class="highlight">
$opt_id = ' id="' . $this->view->escape($id) . '-optgroup-'
        . $this->view->escape($opt_value) . '"';

$list[] = '';

This breaks when the label contains spaces or html entities, e.g. "Waren & Fremdleistungen", both spaces and & are not allowed in ids.

Comments

Posted by Frank Brückner (frosch) on 2012-02-10T07:30:02.000+0000

Code tags added.

Posted by Adam Lundrigan (adamlundrigan) on 2012-02-25T17:23:12.000+0000

Confirmed. Label value is not filtered before being used in the optgroup id.

<pre class="highlight">
1) Zend_View_Helper_FormSelectTest::testHtml4OptGroupLabelIsProperlySantiziedBeforeUseInId
onetwo
Failed asserting that  matches PCRE pattern "/]*?id="baz-optgroup-FooBAR"[^>]*?/".

tests/Zend/View/Helper/FormSelectTest.php:347

2) Zend_View_Helper_FormSelectTest::testHtml5OptGroupLabelIsProperlySantiziedBeforeUseInId
onetwo
Failed asserting that  matches PCRE pattern "/]*?id="baz-optgroup-Foo&&BAR"[^>]*?/".

tests/Zend/View/Helper/FormSelectTest.php:365

Attached patch which corrects this behavior, according to id element rules found here: http://stackoverflow.com/a/79022

Posted by Adam Lundrigan (adamlundrigan) on 2012-02-25T17:26:55.000+0000

One thing to note is that the label value is escaped before being used in the id, which means & -> &. Not sure if this is the intended behavior.

Have you found an issue?

See the Overview section for more details.

Copyright

© 2006-2016 by Zend, a Rogue Wave Company. Made with by awesome contributors.

This website is built using zend-expressive and it runs on PHP 7.

Contacts