Home » HTML » HTML_QuickForm » Bug #8414
eval errors in QuickForm/element.php
Details
| Submitted | 2006-08-10 20:13 UTC |
|---|---|
| From | kjh at flyballdogs dot com |
| Status | Duplicate |
| Package | HTML_QuickForm |
| PHP Version | 5.1.4 |
| OS | Fedora Core 5 |
| Roadmaps | (Not assigned) |
Comments
[2006-08-10 20:13 UTC] kjh at flyballdogs dot com
Description:
------------
I have a form where I am creating elements with names that may contain single quotes and these elements are part of a group.
$elements[] =& $this->createElement('checkbox',
"O'Brien",
null, "Dan O'Brien",
$attrs);
$this->addGroup($elements, 'roster', null, "<br>\n");
The addGroup call creates an error in the eval statement in
element.php _findValue. Its trying to eval a string that contains roster[O'Brien] for example. I fixed this by changing
$myVar = "['" . str_replace(array(']', '['), array('', "']['"), $elementName) . "']";
to
$myVar = "['" . str_replace(array(']', '['), array('', "']['"),
addslashes($elementName)) . "']";
_prepareValue has a similar problem and I changed it from
$myIndex = "['" . str_replace(array(']', '['), array('', "']['"), $name) . "']";
to
$myIndex = "['" . str_replace(array(']', '['), array('', "']['"), addslashes($name)) . "']";
and everything appears to work correctly now.