php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #27299 Preg_replace cannot handle ticks(')
Submitted: 2004-02-17 21:19 UTC Modified: 2004-02-18 02:50 UTC
From: john at supernerd dot com Assigned:
Status: Not a bug Package: PCRE related
PHP Version: 4.3.4 OS: Windows 2000
Private report: No CVE-ID: None
View Add Comment Developer Edit
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:
33 - 25 = ?
Subscribe to this entry?

 
 [2004-02-17 21:19 UTC] john at supernerd dot com
Description:
------------
returns an error of 
Parse error: parse error, unexpected T_CONSTANT_ENCAPSED_STRING in C:\Documents and Settings\john\Desktop\ttms desktop\php\gui\Smarty_Compiler.class.php(288) : regexp code on line 2


Reproduce code:
---------------
$ldq = preg_quote('{', '!');
$rdq = preg_quote('}', '!');
$search = "!{$ldq}\*(.*?)\*{$rdq}|{$ldq}\s*literal\s*{$rdq}(.*?){$ldq}\s*/literal\s*{$rdq}|{$ldq}\s*php\s*{$rdq}(.*?){$ldq}\s*/php\s*{$rdq}!s";
$source_content = preg_replace($search.'e', "'"
                                       . '{' . 'php'
                                       . "' . str_repeat(\"\n\", substr_count('\\0', \"\n\")) .'"
                                       . '}'
                                       . "'",
                                       "a {literal}b{/literal}c{php}d;s{/php}e{* hello's *}");


Expected result:
----------------
a{php}c{php}e{php}

Actual result:
--------------
Parse error: parse error, unexpected T_CONSTANT_ENCAPSED_STRING in C:\Documents and Settings\john\Desktop\ttms desktop\php\index.php(17) : regexp code on line 2

Fatal error: Failed evaluating code: '{php' . str_repeat(" ", substr_count('{* hello''s *}', " ")) .'}' in C:\Documents and Settings\john\Desktop\ttms desktop\php\index.php on line 17

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2004-02-17 21:27 UTC] gschlossnagle@php.net
works fine on mac/linux.  
 [2004-02-17 21:59 UTC] john at supernerd dot com
yeah, I tested on mac/linux.  It only fails on windows.
 [2004-02-17 23:16 UTC] sniper@php.net
Please try using this CVS snapshot:

  http://snaps.php.net/php4-STABLE-latest.tar.gz
 
For Windows:
 
  http://snaps.php.net/win32/php4-win32-STABLE-latest.zip

Works fine in win32 using latest CVS snapshot..

 [2004-02-18 00:44 UTC] john at supernerd dot com
I found that only with magic_quotes_sybase on did the error occur.  I was then able to work around it. I will try the cvs snapshot tomorrow and let you know what happens.
 [2004-02-18 02:50 UTC] sniper@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

Just don't use magic_quotes_*...

 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Mar 29 00:01:28 2024 UTC