8000 [Console] Different behaviour for key and value inputs in case of "." character · Issue #22706 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[Console] Different behaviour for key and value inputs in case of "." character #22706

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
maks-rafalko opened this issue May 12, 2017 · 1 comment

Comments

@maks-rafalko
Copy link
Contributor
maks-rafalko commented May 12, 2017
Q A
Bug report? yes
Feature request? no
BC Break report? no
RFC? yes
Symfony version ^3.2

I would like to know if it is a real bug or intended behaviour:

I'm using ChoiceQuestion with choices of folders, where I can have . and .. among other results, e.g.:

    [1] .
    [2] app
    [3] src

When I type "." I get an error: Value "." is invalid because of regular expression: '/^[a-zA-Z0-9_-]+(?:,[a-zA-Z0-9_-]+)*$/'.

But when I type "1", the value correctly passes validation and ChoiceQuestion returns array(1) { [0] => string(1) "."}.

I think both variant ("." and "1") should be allowed in this case.


If you think this is a bug, what would you like to see as a solution:

  • allowing some range of special characters in the regular expression
  • allow providing custom regular expression
  • something else

(I want to contribute for the first time to Symfony so directions/advices are much appreciated)

Thank you.

@flip111
Copy link
Contributor
flip111 commented May 15, 2017

@borNfreee you can make a pull request to change the regular expression to allow for anything that is not whitespace or a comma. The current regex is making too many assumptions on the use case. Better to allow as much as possible for a generic class like ChoiceQuestion and when people want to limit the characters in the choices they are better of writing their own class that is specific for their problem.

fabpot added a commit that referenced this issue May 27, 2017
…inputs in multiple choice question (borNfreee)

This PR was squashed before being merged into the 2.7 branch (closes #22718).

Discussion
----------

[Console] Fixed different behaviour of key and value user inputs in multiple choice question

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

Fixed a bug when value from multiple choice list could not be selected by user's input
while it could be selected by typing its index in the list.

Commits
-------

2861bd7 [Console] Fixed different behaviour of key and value user inputs in multiple choice question
@fabpot fabpot closed this as completed May 27, 2017
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
0