php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #15050 preg_replace backslashes " or ' character
Submitted: 2002-01-15 10:07 UTC Modified: 2002-01-15 10:59 UTC
Votes:1
Avg. Score:4.0 ± 0.0
Reproduced:0 of 0 (0.0%)
From: joyeux at 1984 dot cz Assigned:
Status: Not a bug Package: PCRE related
PHP Version: 4.1.0 OS: MDK Linux
Private report: No CVE-ID: None
 [2002-01-15 10:07 UTC] joyeux at 1984 dot cz
<?

$text=' something and one " ';
  echo("$text\n");
 
$text=preg_replace("/(.*)/e","'\\1'",$text);
  echo($text);

?>

output:

something and one "
something and one \"


- in executable mode preg_replace adds a backslash. Why?
I think it shouldn't do anything with.

- it's the same when I use ' instead ", but switched.

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-01-15 10:59 UTC] sander@php.net
Not a bug. RTM on Magic Quotes.
 [2004-03-31 11:32 UTC] php at derailer dot org
This still occurs for me, but only with double quotes. I turned off every magic_quotes_* directive in php.ini just to be sure, and it still happens, just as described here. Single quotes, and literal backslashes *are not affected* for me at all.

PHP 4.3.5, BTW.
 [2004-08-02 21:22 UTC] abodeman at yahoo dot com
This is NOT a bogus bug. Sander, it is NOT due to that awful PHP kludge called Magic Quotes. Magic Quotes puts backslashes into data received through $_GET, $_POST, or $_COOKIE. None of those are being used here.

Due to this bug, I am going to have to write my own character-by-character string replacer, or fire up Perl in the background with backticks. I hate PHP.
 [2004-08-02 21:23 UTC] jhelzer at cse dot unl dot edu
This is hardy bogus.  GPC isn't even involved, just look at the code sample.

This bug is ludicrous.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Dec 22 06:01:30 2024 UTC