File tree Expand file tree Collapse file tree 2 files changed +7
-3
lines changed
src/Symfony/Component/Console Expand file tree Collapse file tree 2 files changed +7
-3
lines changed Original file line number Diff line number Diff line change @@ -50,7 +50,8 @@ public static function escapeTrailingBackslash($text)
50
50
if ('\\' === substr ($ text , -1 )) {
51
51
$ len = strlen ($ text );
52
52
$ text = rtrim ($ text , '\\' );
53
- $ text .= str_repeat ('<< ' , $ len - strlen ($ text ));
53
+ $ text = str_replace ("\0" , '' , $ text );
54
+ $ text .= str_repeat ("\0" , $ len - strlen ($ text ));
54
55
}
55
56
56
57
return $ text ;
@@ -165,8 +166,8 @@ public function format($message)
165
166
166
167
$ output .= $ this ->applyCurrentStyle (substr ($ message , $ offset ));
167
168
168
- if (false !== strpos ($ output , ' << ' )) {
169
- return strtr ($ output , array ('\\ < ' => '< ' , '<< ' => '\\ ' ));
169
+ if (false !== strpos ($ output , "\0" )) {
170
+ return strtr ($ output , array ("\0" => '\\ ' , '\\ < ' => '< ' ));
170
171
}
171
172
172
173
return str_replace ('\\< ' , '< ' , $ output );
Original file line number Diff line number Diff line change @@ -28,6 +28,9 @@ public function testLGCharEscaping()
28
28
$ formatter = new OutputFormatter (true );
29
29
30
30
$ 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> \\' ));
31
34
$ this ->assertEquals ('<info>some info</info> ' , $ formatter ->format ('\\<info>some info \\</info> ' ));
32
35
$ this ->assertEquals ('\\<info>some info \\</info> ' , OutputFormatter::escape ('<info>some info</info> ' ));
33
36
You can’t perform that action at this time.
0 commit comments