php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #31341 escape on curly inconsistent
Submitted: 2004-12-30 02:57 UTC Modified: 2005-10-21 15:22 UTC
Votes:2
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: nmuhayimana at semanticdesigns dot com Assigned: dmitry (profile)
Status: Closed Package: Scripting Engine problem
PHP Version: 5CVS, 4CVS (2005-08-25) OS: *
Private report: No CVE-ID: None
 [2004-12-30 02:57 UTC] nmuhayimana at semanticdesigns dot com
Description:
------------
Php suppresses the backslash before left curly brace using
"action at distance", violating the "principle of least surprise".

Apparently the backslash is suppressed if there is any non-escaped dollar sign any where in the string.  

Reproduce code:
---------------
<?php

echo ("$     \{    \n"); 
echo ("      \{   $\n"); 
echo ("      \{$   \n");
echo ("      $\{   \n");
echo ("      \$\{  \n");
echo ("      \{\$  \n");
echo ("\$    \{    \n");
echo ("      \{  \$\n");
echo ("%     \{    \n");
?>

Expected result:
----------------
$     \{      
      \{   $   
      {$         
      $\{     
      $\{  
      \{$  
$    \{    
      \{  $
%     \{    

Actual result:
--------------
$     {    
      {   $
      {$   
      ${   
      $\{  
      \{$  
$    \{    
      \{  $
%     \{    

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-02-21 20:42 UTC] sniper@php.net
Andi, is this _really_ intentional? :)

 [2005-05-18 12:33 UTC] stas@php.net
I think there's an omission in ST_IN_SCRIPTING state backshlash handling (around line 1525 of lex file) - unlike ST_DOUBLE_QUOTES state, it does not convert \{ to {. I think they should be brought together, though I'm not sure which one should win - should \{ be left as is or translated to {? 
 [2005-08-03 14:05 UTC] gopalv82 at yahoo dot com
All it needs is just one case '{': in the 
ST_IN_SCRIPTING state's quoted string handling ?.
 [2005-10-21 15:22 UTC] dmitry@php.net
Fixed in CVS HEAD and PHP_5_1.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Mar 19 09:01:30 2024 UTC