|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2009-11-06 09:18 UTC] zhongxueming at gmail dot com
Description:
------------
When I execute a sql by Zend DB, I got a connection error,
and found an error in apache error log.
After tracking, I found the problem is preg_replace function.
I think you can replay this problem by the test code.
Env:
Windows XP, Windows Server 2003
Apache 2.2.13
PHP php-5.2.11
Reproduce code:
---------------
function testPregReplace() {
$sql = "SELECT \"t_skill_label\".\"c_name\" FROM \"t_skill_label\" WHERE (\"c_name\" = '????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????') AND (\"c_id\" != '3') LIMIT 1";
echo preg_replace("/'(''|\\\\{2}|[^'])*'/", '', $sql);
}
testPregReplace();
Expected result:
----------------
Apache not be restarted.
Actual result:
--------------
This test code will cause apache error.
You can confirm it in the apache error log.
The browser display a connection error.
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Tue Oct 28 07:00:01 2025 UTC |
Hi. I think I have the same problem like the editor of this bug. I am using PHP 5.3.8 on Windows 7. But my RegEx is a little bit different. The bug occurs only on Windows if the script is executed via Apache. I have no problems on Linux and no problem if I execute the script via Windows Shell. Debug and APC modules are deactivated already. I have generated a backtrace already, but I don't know where to upload it. Reproduce code: --------------- <?php $sql = "INSERT INTO `oo` (`to`,`subject`,`text`,`creation_time`) VALUES ('','',''),('','','',''),('','','','ooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo')"; $sql = preg_replace("/'(\\'|\\{2}|[^'])*'/", '', $sql); echo $sql; ?> Expected result: --------------- INSERT INTO `oo` (`to`,`subject`,`text`,`creation_time`) VALUES () Actual result: --------------- The connection to the server is refused. But if I remove one or more of the many 'o's, the script works fine.