diff --git a/src/Composer/Console/HtmlOutputFormatter.php b/src/Composer/Console/HtmlOutputFormatter.php
index cd8c7fd4e..cb42133c3 100644
--- a/src/Composer/Console/HtmlOutputFormatter.php
+++ b/src/Composer/Console/HtmlOutputFormatter.php
@@ -59,7 +59,8 @@ class HtmlOutputFormatter extends OutputFormatter
{
$formatted = parent::format($message);
- return preg_replace_callback("{\033\[([0-9;]+)m(.*?)\033\[(?:39|49|0|22|24|25|27|28)m}s", array($this, 'formatHtml'), $formatted);
+ $clearEscapeCodes = '(?:39|49|0|22|24|25|27|28)';
+ return preg_replace_callback("{\033\[([0-9;]+)m(.*?)\033\[(?:".$clearEscapeCodes.";)*?".$clearEscapeCodes."m}s", array($this, 'formatHtml'), $formatted);
}
private function formatHtml($matches)
diff --git a/tests/Composer/Test/Console/HtmlOutputFormatterTest.php b/tests/Composer/Test/Console/HtmlOutputFormatterTest.php
index 758087b9a..8beb41943 100644
--- a/tests/Composer/Test/Console/HtmlOutputFormatterTest.php
+++ b/tests/Composer/Test/Console/HtmlOutputFormatterTest.php
@@ -13,16 +13,19 @@
namespace Composer;
use Composer\Console\HtmlOutputFormatter;
+use Symfony\Component\Console\Formatter\OutputFormatterStyle;
class HtmlOutputFormatterTest extends \PHPUnit_Framework_TestCase
{
public function testFormatting()
{
- $formatter = new HtmlOutputFormatter;
+ $formatter = new HtmlOutputFormatter(array(
+ 'warning' => new OutputFormatterStyle('black', 'yellow'),
+ ));
return $this->assertEquals(
- 'Reading composer.json of https://github.com/ccqgithub/sherry-php (master)',
- $formatter->format('Reading composer.json of https://github.com/ccqgithub/sherry-php (master)')
+ 'text green yellow black w/ yello bg',
+ $formatter->format('text green yellow black w/ yello bg')
);
}
}