PEAR is discontinued

This is a static archive preserving historical releases and metadata. No new packages or updates will be published. For updates to existing packages, or to publish new packages, please use Composer and Packagist.

Home » HTML » HTML_QuickForm » Bug #8414

eval errors in QuickForm/element.php

Details

Submitted2006-08-10 20:13 UTC
Fromkjh at flyballdogs dot com
StatusDuplicate
PackageHTML_QuickForm
PHP Version5.1.4
OSFedora 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.