From 80065965d3665c6fbd27a71b04f9a557fad31e9e Mon Sep 17 00:00:00 2001 From: nikic Date: Sun, 4 Dec 2011 17:35:30 +0100 Subject: [PATCH] [5.4] Add new \e escape sequence (0x1B/27) --- lib/PHPParser/Node/Scalar/String.php | 3 ++- test/PHPParser/Tests/Node/Scalar/StringTest.php | 1 + test/code/scalar/constantString.test | 4 ++-- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/PHPParser/Node/Scalar/String.php b/lib/PHPParser/Node/Scalar/String.php index e28bf61..e33fd3a 100644 --- a/lib/PHPParser/Node/Scalar/String.php +++ b/lib/PHPParser/Node/Scalar/String.php @@ -13,6 +13,7 @@ class PHPParser_Node_Scalar_String extends PHPParser_Node_Scalar 't' => "\t", 'f' => "\f", 'v' => "\v", + 'e' => "\x1B", ); /** @@ -73,7 +74,7 @@ class PHPParser_Node_Scalar_String extends PHPParser_Node_Scalar } return preg_replace_callback( - '~\\\\([\\\\$nrtfv]|[xX][0-9a-fA-F]{1,2}|[0-7]{1,3})~', + '~\\\\([\\\\$nrtfve]|[xX][0-9a-fA-F]{1,2}|[0-7]{1,3})~', array(__CLASS__, 'parseCallback'), $str ); diff --git a/test/PHPParser/Tests/Node/Scalar/StringTest.php b/test/PHPParser/Tests/Node/Scalar/StringTest.php index bae3d90..cce7617 100644 --- a/test/PHPParser/Tests/Node/Scalar/StringTest.php +++ b/test/PHPParser/Tests/Node/Scalar/StringTest.php @@ -28,6 +28,7 @@ class PHPParser_Tests_Node_Scalar_StringTest extends PHPUnit_Framework_TestCase array('\\"', '\\"', '`'), array('\\"\\`', '\\"\\`', null), array("\\\$\n\r\t\f\v", '\\\\\$\n\r\t\f\v', null), + array("\x1B", '\e', null), array(chr(255), '\xFF', null), array(chr(255), '\377', null), array(chr(0), '\400', null), diff --git a/test/code/scalar/constantString.test b/test/code/scalar/constantString.test index cd3eda0..b7d6843 100644 --- a/test/code/scalar/constantString.test +++ b/test/code/scalar/constantString.test @@ -11,7 +11,7 @@ b'Hi'; "Hi"; b"Hi"; '!\'!\\!\a!'; -"!\"!\\!\$!\n!\r!\t!\f!\v!\a"; +"!\"!\\!\$!\n!\r!\t!\f!\v!\e!\a"; "!\xFF!\377!\400!\0!"; ----- array( @@ -45,7 +45,7 @@ array( 9: Scalar_String( value: !"!\!$! ! -! ! ! !\a +!@@{ chr(9) }@@!@@{ chr(12) }@@!@@{ chr(11) }@@!@@{ chr(27) }@@!\a ) 10: Scalar_String( value: !@@{ chr(255) }@@!@@{ chr(255) }@@!@@{ chr(0) }@@!@@{ chr(0) }@@!