[Console] Fixed output bug, if escaped string in a formatted string.
This commit is contained in:
parent
d9c0c55ace
commit
1c62eb77e0
@ -150,6 +150,10 @@ class OutputFormatter implements OutputFormatterInterface
|
||||
$pos = $match[1];
|
||||
$text = $match[0];
|
||||
|
||||
if (0 != $pos && '\\' == $message[$pos - 1]) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// add the text up to the next tag
|
||||
$output .= $this->applyCurrentStyle(substr($message, $offset, $pos - $offset));
|
||||
$offset = $pos + strlen($text);
|
||||
@ -164,9 +168,6 @@ class OutputFormatter implements OutputFormatterInterface
|
||||
if (!$open && !$tag) {
|
||||
// </>
|
||||
$this->styleStack->pop();
|
||||
} elseif ($pos && '\\' == $message[$pos - 1]) {
|
||||
// escaped tag
|
||||
$output .= $this->applyCurrentStyle($text);
|
||||
} elseif (false === $style = $this->createStyleFromString(strtolower($tag))) {
|
||||
$output .= $this->applyCurrentStyle($text);
|
||||
} elseif ($open) {
|
||||
|
@ -101,6 +101,11 @@ class OutputFormatterTest extends \PHPUnit_Framework_TestCase
|
||||
"(\033[32mz>=2.0,<a2.3\033[0m)",
|
||||
$formatter->format('(<info>'.$formatter->escape('z>=2.0,<a2.3').'</info>)')
|
||||
);
|
||||
|
||||
$this->assertEquals(
|
||||
"\033[32m<error>some error</error>\033[39m",
|
||||
$formatter->format('<info>'.$formatter->escape('<error>some error</error>').'</info>')
|
||||
);
|
||||
}
|
||||
|
||||
public function testDeepNestedStyles()
|
||||
|
Reference in New Issue
Block a user