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)
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- return strtr ($ output , array ('\\ < ' => '< ' , '<< ' => '\\ ' ));
169+ if (false !== strpos ($ output , "\0" )) {
170+ return strtr ($ output , array ("\0" => '\\ ' , '\\ < ' => '< ' ));
170171 }
171172
172173 return str_replace ('\\< ' , '< ' , $ output );
Original file line number Diff line number Diff line change @@ -28,6 +28,9 @@ public function testLGCharEscaping()
2828 $ formatter = new OutputFormatter (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
You can’t perform that action at this time.
0 commit comments