Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitd5cb1fe

Browse files
javiereguiluzfabpot
authored andcommitted
Fixed the escaping of back slashes and << in console output
1 parent8f5141d commitd5cb1fe

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,8 @@ public static function escapeTrailingBackslash($text)
5050
if ('\\' ===substr($text, -1)) {
5151
$len =strlen($text);
5252
$text =rtrim($text,'\\');
53-
$text .=str_repeat('<<',$len -strlen($text));
53+
$text =str_replace("\0",'',$text);
54+
$text .=str_repeat("\0",$len -strlen($text));
5455
}
5556

5657
return$text;
@@ -165,8 +166,8 @@ public function format($message)
165166

166167
$output .=$this->applyCurrentStyle(substr($message,$offset));
167168

168-
if (false !==strpos($output,'<<')) {
169-
returnstrtr($output,array('\\<' =>'<','<<' =>'\\'));
169+
if (false !==strpos($output,"\0")) {
170+
returnstrtr($output,array("\0" =>'\\','\\<' =>'<'));
170171
}
171172

172173
returnstr_replace('\\<','<',$output);

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ public function testLGCharEscaping()
2828
$formatter =newOutputFormatter(true);
2929

3030
$this->assertEquals('foo<bar',$formatter->format('foo\\<bar'));
31+
$this->assertEquals('foo << bar',$formatter->format('foo << bar'));
32+
$this->assertEquals('foo << bar\\',$formatter->format('foo << bar\\'));
33+
$this->assertEquals("foo <<\033[32mbar\\ baz\033[39m\\",$formatter->format('foo << <info>bar\\ baz</info>\\'));
3134
$this->assertEquals('<info>some info</info>',$formatter->format('\\<info>some info\\</info>'));
3235
$this->assertEquals('\\<info>some info\\</info>', OutputFormatter::escape('<info>some info</info>'));
3336

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp