Bug #11236 Updated: addslashes() before preg_replace() gives parse error in regexp

From: Date: Mon, 06 Aug 2001 17:09:27 +0000
Subject: Bug #11236 Updated: addslashes() before preg_replace() gives parse error in regexp
References: 1  Groups: php.dev 
Request: Send a blank email to php-dev+get-62317@lists.php.net to get a copy of this message
ID: 11236 Updated by: andrei Reported By: john@vbulletin.com Old Status: Open Status: Closed Bug Type: PCRE related Operating System: Linux PHP Version: 4.0.5 New Comment: This works in latest CVS - try upgrading to 4.0.6 or later. Previous Comments: ------------------------------------------------------------------------ [2001-06-11 10:04:46] john@vbulletin.com Just an update -- this issue seems to be to do with having lots of single quotes (') in the string. It has also been an issue in strings other than the one shown in my first post. 6 quotes seems to be the limit of what it can handle. John ------------------------------------------------------------------------ [2001-06-01 07:11:28] john@vbulletin.com This issue seems to only affect PHP 4.0.5, not earlier versions, as far as I can tell. The following code gives an error: <? $string=" [code] EXEC sp_addlinkedserver 'TillDB', 'Access 2000', 'Microsoft.Jet.OLEDB.4.0', '\\till01\C\endx\data\ct.mdb' EXEC sp_addlinkedsrvlogin 'TillDB', false, NULL, 'Admin', NULL EXEC sp_dropserver 'TIllDB', 'droplogins' [/code] "; function stripbrsfromcode($str) { return ($str); } //$string=str_replace("'","\'",$string); $string=addslashes($string); echo $string; $string=preg_replace("/(\[)(code)(])(\r\n)*(.*)(\[\/code\])/esiU","stripbrsfromcode('\\5')",$string); echo $string; ?> The error is as follows: [code] EXEC sp_addlinkedserver \'TillDB\', \'Access 2000\', \'Microsoft.Jet.OLEDB.4.0\', \'\till01\C\endx\data\ct.mdb\' EXEC sp_addlinkedsrvlogin \'TillDB\', false, NULL, \'Admin\', NULL EXEC sp_dropserver \'TIllDB\', \'droplogins\' [/code] Parse error: parse error in /usr/local/apache/htdocs/test.php(24) : regexp code on line 5 Fatal error: Failed evaluating code: stripbrsfromcode(' EXEC sp_addlinkedserver \\\'TillDB\\\', \\\'Access 2000\\\', \\\'Microsoft.Jet.OLEDB.4.0\\\', \\\'\\till01\\C\\endx\\data\\ct.mdb\\\' EXEC sp_addlinkedsrvlogin \\\'TillDB\\\', false, NULL, \\\'Admin\\\', NULL EXEC sp_dropserver \\'TIllDB\\', \\'droplogins\\' ') in /usr/local/apache/htdocs/test.php on line 24 Let me know if you need other info. I have seen this problem on two independant configurations, so I am fairly sure it is not the server. phpinfo here: http://161.58.186.97/phpinfo.php ------------------------------------------------------------------------ Edit this bug report at http://bugs.php.net/?id=11236&edit=1

« previous php.dev (#62317) next »