17
17
use Symfony \Component \Console \Question \ConfirmationQuestion ;
18
18
use Symfony \Component \Console \Question \Question ;
19
19
use Symfony \Component \Console \Style \SymfonyStyle ;
20
+ use Symfony \Component \Console \Formatter \OutputFormatter ;
20
21
21
22
/**
22
23
* Symfony Style Guide compliant question helper.
@@ -52,7 +53,7 @@ public function ask(InputInterface $input, OutputInterface $output, Question $qu
52
53
*/
53
54
protected function writePrompt (OutputInterface $ output , Question $ question )
54
55
{
55
- $ text = $ question ->getQuestion ();
56
+ $ text = OutputFormatter:: escape ( $ question ->getQuestion () );
56
57
$ default = $ question ->getDefault ();
57
58
58
59
switch (true ) {
@@ -74,18 +75,18 @@ protected function writePrompt(OutputInterface $output, Question $question)
74
75
$ default [$ key ] = $ choices [trim ($ value )];
75
76
}
76
77
77
- $ text = sprintf (' <info>%s</info> [<comment>%s</comment>]: ' , $ text , implode (', ' , $ default ));
78
+ $ text = sprintf (' <info>%s</info> [<comment>%s</comment>]: ' , $ text , OutputFormatter:: escape ( implode (', ' , $ default) ));
78
79
79
80
break ;
80
81
81
82
case $ question instanceof ChoiceQuestion:
82
83
$ choices = $ question ->getChoices ();
83
- $ text = sprintf (' <info>%s</info> [<comment>%s</comment>]: ' , $ text , $ choices [$ default ]);
84
+ $ text = sprintf (' <info>%s</info> [<comment>%s</comment>]: ' , $ text , OutputFormatter:: escape ( $ choices [$ default ]) );
84
85
85
86
break ;
86
87
87
88
default :
88
- $ text = sprintf (' <info>%s</info> [<comment>%s</comment>]: ' , $ text , $ default );
89
+ $ text = sprintf (' <info>%s</info> [<comment>%s</comment>]: ' , $ text , OutputFormatter:: escape ( $ default) );
89
90
}
90
91
91
92
$ output ->writeln ($ text );
0 commit comments