File tree 2 files changed +16
-1
lines changed
src/Illuminate/View/Compilers 2 files changed +16
-1
lines changed Original file line number Diff line number Diff line change @@ -417,7 +417,7 @@ protected function compileExtensions($value)
417
417
protected function compileStatements ($ value )
418
418
{
419
419
return preg_replace_callback (
420
- '/\B@(@?\w+(?:::\w+)?)([ \t]*)(\( ( (?> \'[^ \']* \') | (?>"[^"]*") | (?>[^() \'"]+) | (?3) )* \))?/x ' , function ($ match ) {
420
+ '/\B@(@?\w+(?:::\w+)?)([ \t]*)(\( ( (?> \'(?: \\\\\' | [^ \']) * \') | (?>"(?: \\\\ "| [^"]) *") | (?>[^() \'"]+) | (?3) )* \))?/x ' , function ($ match ) {
421
421
return $ this ->compileStatement ($ match );
422
422
}, $ value
423
423
);
Original file line number Diff line number Diff line change @@ -67,4 +67,19 @@ public function testStringWithEmptyStringDataValue()
67
67
68
68
$ this ->assertEquals ($ expected , $ this ->compiler ->compileString ($ string ));
69
69
}
70
+
71
+ public function testStringWithEscapingDataValue ()
72
+ {
73
+ $ string = "@php( \$data = ['test' => 'won \\'t break']) " ;
74
+
75
+ $ expected = "<?php ( \$data = ['test' => 'won \\'t break']); ?> " ;
76
+
77
+ $ this ->assertEquals ($ expected , $ this ->compiler ->compileString ($ string ));
78
+
79
+ $ string = "@php( \$data = ['test' => \"\\\"escaped \\\"\"]) " ;
80
+
81
+ $ expected = "<?php ( \$data = ['test' => \"\\\"escaped \\\"\"]); ?> " ;
82
+
83
+ $ this ->assertEquals ($ expected , $ this ->compiler ->compileString ($ string ));
84
+ }
70
85
}
You can’t perform that action at this time.
0 commit comments