Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 2.3.2

Bug #18182 Problem with quotes in preg_replace
Submitted: 2011-01-10 06:41 UTC
From: helloworld Assigned: avb
Status: Closed Package: HTML_QuickForm2 (version 0.5.0)
PHP Version: 5.3.1 OS: Ubuntu
Roadmaps: 0.6.0    
Subscription  
Comments Add Comment Add patch


Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know! Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem : 12 + 22 = ?

 
 [2011-01-10 06:41 UTC] helloworld (Kirill Znamenskiy)
Description: ------------ In file Group.php:256 need change this $name = preg_replace('/^' . $this->getName() . '\ [([^\]]*)\]/', '\1', $element->getName()); to this $name = preg_replace('/^' . preg_quote($this->getName()) . '\[([^\]]*)\]/', '\1', $element->getName());

Comments

 [2011-01-10 06:46 UTC] helloworld (Kirill Znamenskiy)
Becase if use name group name like "aa[c-b]" then get warning WARNING: preg_replace(): Compilation failed: range out of order in character class at offset 7
 [2011-01-10 14:56 UTC] mansion (Bertrand Mansion)
-Status: Open +Status: Closed -Assigned To: +Assigned To: mansion
This bug has been fixed in SVN. If this was a documentation problem, the fix will appear on pear.php.net by the end of next Sunday (CET). If this was a problem with the pear.php.net website, the change should be live shortly. Otherwise, the fix will appear in the package's next release. Thank you for the report and for helping us make PEAR better.
 [2011-01-10 15:08 UTC] mansion (Bertrand Mansion)
-Status: Closed +Status: Open
Actually, I couldn't reproduce this, can you post an example please ?
 [2011-01-11 19:01 UTC] helloworld (Kirill Znamenskiy)
Sorry, I'm not explain so accurate. If use simple group then all ok, but if use hierselect then we get this problem. I'm not find how attach file, so example below: require_once('HTML/QuickForm2.php'); require_once('HTML/QuickForm2/Renderer.php'); $form = new HTML_QuickForm2('example'); $el = $form->addElement('hierselect', 'aa[c-b]', array('style' => 'width: 300px;'), array('label' => 'Example', 'separator' => '<br/>')); $el->loadOptions(array( array('1', '2', '3'), array( array('11','12','13'), array('21','22','23'), array('31','32','33') ) )); $renderer = HTML_QuickForm2_Renderer::factory('default'); $form->render($renderer); echo $renderer->getJavascriptBuilder()->getLibraries(true, true); echo $renderer;
 [2011-01-12 03:11 UTC] avb (Alexey Borzov)
-Status: Assigned +Status: Closed -Assigned To: mansion +Assigned To: avb
Hierselect triggered this because it does appendChild() / removeChild() in its render method. I added a method to check for this to a unit test for Group class and changed the provided fix a bit.
 [2011-07-01 00:04 UTC] pagenotes (Jim Williams)
This bug is still in version 5.3.5, as packaged with XAMPP 1.7.4 on Windows XP home edition. Even some very simple examples exhibit the problem, e.g., $pattern = '/^[\w_-. ]+$/'; $uid = 'guest'; if (preg_match($pattern, $uid)) echo ("<style> p { text-decoration:line-through } </style>");
 [2012-02-22 00:27 UTC] vitalij (Vitalij Surname)
Hi! I still have this problem on my computer - I use the PHP 5.3.6-13 ubuntu 3.6 with Suhosin-Patch (cli) (built: Feb 11 2012 03:26:01)