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
This commit is contained in:
Fabien Potencier 2012-07-13 11:28:57 +02:00
commit 7dc89013eb
2 changed files with 8 additions and 1 deletions

View File

@ -23,7 +23,7 @@ class OutputFormatter implements OutputFormatterInterface
/**
* The pattern to phrase the format.
*/
const FORMAT_PATTERN = '#(\\\\?)<(/?)([a-z][a-z0-9_=;-]+)?>([^\\\\<]*)#is';
const FORMAT_PATTERN = '#(\\\\?)<(/?)([a-z][a-z0-9_=;-]+)?>((?:(?!\\\\?<).)*)#is';
private $decorated;
private $styles = array();

View File

@ -9,6 +9,7 @@
* file that was distributed with this source code.
*/
namespace Symfony\Component\Console\Tests\Formatter;
use Symfony\Component\Console\Formatter\OutputFormatter;
@ -25,9 +26,15 @@ class FormatterStyleTest extends \PHPUnit_Framework_TestCase
public function testLGCharEscaping()
{
$formatter = new OutputFormatter(true);
$this->assertEquals("foo<bar", $formatter->format('foo\\<bar'));
$this->assertEquals("<info>some info</info>", $formatter->format('\\<info>some info\\</info>'));
$this->assertEquals("\\<info>some info\\</info>", OutputFormatter::escape('<info>some info</info>'));
$this->assertEquals(
"\033[33mSymfony\\Component\\Console does work very well!\033[0m",
$formatter->format('<comment>Symfony\Component\Console does work very well!</comment>')
);
}
public function testBundledStyles()