8000 [Console] Fix style escaping parsing · symfony/symfony@eb93e66 · GitHub
[go: up one dir, main page]

Skip to content

Commit eb93e66

Browse files
committed
[Console] Fix style escaping parsing
1 parent 8ca1b80 commit eb93e66

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

src/Symfony/Component/Console/Formatter/OutputFormatter.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ class OutputFormatter implements OutputFormatterInterface
2323
/**
2424
* The pattern to phrase the format.
2525
*/
26-
const FORMAT_PATTERN = '#(\\\\?)<(/?)([a-z][a-z0-9_=;-]+)?>((?:(?!\\\\?<(?:/?[a-z]|/>)).)*)#is';
26+
const FORMAT_PATTERN = '#(\\\\?)<(/?)([a-z][a-z0-9_=;-]+)?>((?: [^<\\\\]+ | (?!<(?:/?[a-z]|/>)). | .(?<=\\\\<) )*)#isx';
2727

2828
private $decorated;
2929
private $styles = array();

src/Symfony/Component/Console/Tests/Formatter/OutputFormatterTest.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,16 @@ public function testStyleMatchingNotGreedy()
8383
);
8484
}
8585

86+
public function testStyleEscaping()
87+
{
88+
$formatter = new OutputFormatter(true);
89+
90+
$this->assertEquals(
91+
"(\033[32mz>=2.0,<a2.3\033[0m)",
92+
$formatter->format('(<info>'.$formatter->escape('z>=2.0,<a2.3').'</info>)')
93+
);
94+
}
95+
8696
public function testDeepNestedStyles()
8797
{
8898
$formatter = new OutputFormatter(true);

0 commit comments

Comments
 (0)
0