8000 merged branch jfsimon/issue-4885 (PR #4891) · symfony/symfony@7dc8901 · GitHub
[go: up one dir, main page]

Skip to content
8000

Commit 7dc8901

Browse files
committed
merged branch jfsimon/issue-4885 (PR #4891)
Commits ------- 3fef3c2 [Console] Fixed output formatter regex. fea9d09 [Console] Added LG char escaping test. Discussion ---------- Issue 4885 Bug fix: yes Feature addition: no Backwards compatibility break: no Symfony2 tests pass: yes Fixes the following tickets: #4885
2 parents 295860d + 3fef3c2 commit 7dc8901

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-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_=;-]+)?>([^\\\\<]*)#is';
26+
const FORMAT_PATTERN = '#(\\\\?)<(/?)([a-z][a-z0-9_=;-]+)?>((?:(?!\\\\?<).)*)#is';
2727

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

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
* file that was distributed with this source code.
1010
*/
1111

12+
1213
namespace Symfony\Component\Console\Tests\Formatter;
1314

1415
use Symfony\Component\Console\Formatter\OutputFormatter;
@@ -25,9 +26,15 @@ public function testEmptyTag()
2526
public function testLGCharEscaping()
2627
{
2728
$formatter = new OutputFormatter(true);
29+
2830
$this->assertEquals("foo<bar", $formatter->format('foo\\<bar'));
2931
$this->assertEquals("<info>some info</info>", $formatter->format('\\<info>some info\\</info>'));
3032
$this->assertEquals("\\<info>some info\\</info>", OutputFormatter::escape('<info>some info</info>'));
33+
34+
$this->assertEquals(
35+
"\033[33mSymfony\\Component\\Console does work very well!\033[0m",
36+
$formatter->format('<comment>Symfony\Component\Console does work very well!</comment>')
37+
);
3138
}
3239

3340
public function testBundledStyles()

0 commit comments

Comments
 (0)
0