Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[Console] SymfonyQuestionHelper escapes formatting in question prompts #20964

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
polothy opened this issue Dec 16, 2016 · 3 comments
Closed

[Console] SymfonyQuestionHelper escapes formatting in question prompts #20964

polothy opened this issue Dec 16, 2016 · 3 comments

Comments

@polothy
Copy link

polothy commented Dec 16, 2016

Q A
Bug report? yes
Feature request? no
BC Break report? yes (I think?)
RFC? no
Symfony version 3.2.1

I'm very late to the Symfony 3 upgrade game, but in comparison to Symfony 2.8, this code behaves differently:

$io = new SymfonyStyle($input, $output);
$io->confirm('Are you sure you want to <comment>something</comment>');

Expected output is that the word "something" has a different color, instead the output is as follows:

Are you sure you want to <comment>something</comment> (yes/no) [yes]:
 >

This is due to this commit. From the tests, it seems like the escape was added just for backslashes and not really intended to also escape formatting.

Maybe this is too late into Symfony 3 to change this behavior, but it is handy to be able to emphasize words in questions.

@chalasr
Copy link
Member

chalasr commented Dec 17, 2016

Thank you for reporting this bug. See #20970

@chalasr
Copy link
Member

chalasr commented Dec 17, 2016

Status: Reviewed

@polothy
Copy link
Author

polothy commented Dec 18, 2016

Thanks very much for looking at this so quickly, cheers!

fabpot added a commit that referenced this issue Dec 22, 2016
…) (chalasr, ogizanagi)

This PR was merged into the 2.7 branch.

Discussion
----------

[Console] Fix question formatting using SymfonyStyle::ask()

| Q             | A
| ------------- | ---
| Branch?       | 2.7
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #20964
| License       | MIT
| Doc PR        | n/a

Given
```php
$io = new SymfonyStyle($input, $output);
$io->ask('Do you want to use Foo\\Bar <comment>or</comment> Foo\\Baz\\?', 'Foo\\Bar');
```

Before output
![before](http://image.prntscr.com/image/af3806f866654deda2dec79b50d1ffa2.png)

After output
![after](http://image.prntscr.com/image/59c031d9e02949cebeae7a4734c7043f.png)

Commits
-------

e189183 [Console] SymfonyStyle: Escape trailing backslashes in user texts
9d46712 [Console] Fix question formatting using SymfonyStyle::ask()
@fabpot fabpot closed this as completed Dec 22, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants