php preg_replace bug ??

這個問題在在Zend Framework 中
Zend/Db/Statement.php
裡面
[cc lang="php" tab_size="2" lines="40"]
protected function _stripQuoted($sql)
{
// get the character for delimited id quotes,
// this is usually ” but in MySQL is `
$d = $this->_adapter->quoteIdentifier(‘a’);
$d = $d[0];

// get the value used as an escaped delimited id quote,
// e.g. \” or “” or \`
$de = $this->_adapter->quoteIdentifier($d);
$de = substr($de, 1, 2);
$de = str_replace(‘\\’, ‘\\\\’, $de);

// get the character for value quoting
// this should be ‘
$q = $this->_adapter->quote(‘a’);
$q = $q[0];

// get the value used as an escaped quote,
// e.g. \’ or ”
$qe = $this->_adapter->quote($q);
$qe = substr($qe, 1, 2);
$qe = str_replace(‘\\’, ‘\\\\’, $qe);

// get a version of the SQL statement with all quoted
// values and delimited identifiers stripped out
// remove “foo\”bar”
$sql = preg_replace(“/$q($qe|\\\\{2}|[^$q])*$q/”, ”, $sql);
// remove ‘foo\’bar’
if (!empty($q)) {
$sql = preg_replace(“/$q($qe|[^$q])*$q/”, ”, $sql);
}

return $sql;
}

[/cc]
發現的
我是要執行一段db->query($sql)
sql 是 insert into xxx
有把sql 單純的print 出來到mysql 中執行是可以成功執行的
trace 到最後發現會卡在preg_replace這邊
而看httpd error , access log 都沒有訊息
看message log 就會出現
Nov 12 13:22:33 mail kernel: pid 50728 (httpd), uid 80: exited on signal 4
所以判斷應該是
php 的bug

我的解法是不用preg_replace 換成
ereg_replace, mb_ereg_replace
都可以.

About johnpupu

..........
This entry was posted in program and tagged . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

*
To prove you're a person (not a spam script), type the security word shown in the picture. Click on the picture to hear an audio file of the word.
Click to hear an audio file of the anti-spam word