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

Skip to content
This repository was archived by the owner on Nov 14, 2019. It is now read-only.

Fix version validation rule to use full-matching #6

Closed
wants to merge 2 commits into from
Closed

Fix version validation rule to use full-matching #6

wants to merge 2 commits into from

Conversation

fivestar
Copy link
Contributor

Currently:

% symfony new blog/ a2.2.5

 Downloading Symfony...

  [GuzzleHttp\Exception\ClientException]                                                                                              
  Client error response [url] http://get.symfony.com/Symfony_Standard_Vendors_a2.2.5.zip [status code] 403 [reason phrase] Forbidden  

new name [version]

After fixed:

% symfony new blog/ a2.2.5

  [RuntimeException]                                                 
  The Symfony version should be 2.N.M, where N = 0..9 and M = 0..99  

new name [version]

@stof
Copy link
Member

stof commented Oct 16, 2014

why not using ^ and $ instead ?

@fivestar
Copy link
Contributor Author

So \A and \z match head and end collectly than ^ and $.
Is it bothering you?

@sivolobov
Copy link

\A and \z can be useful for multiline input where ^ and $ will match begining and ending of every line, \A and \z will match only begining and ending of whole input text.

I think that @stof is right. Because you always will have one line in input for version number.

@stof
Copy link
Member

stof commented Oct 16, 2014

but here, we are not in a multiline regex (we don't have the m modifier), so they are equivalent. I would rather use ^ and $, to be consistent with the Symfony codebase

@fivestar
Copy link
Contributor Author

OK. I fixed it for consistency.

@kenjis
Copy link

kenjis commented Oct 16, 2014

Just for your information.

but here, we are not in a multiline regex (we don't have the m modifier), so they are equivalent.

They are not equivalent.

$ matches "\n" at the end, but \z does not match "\n" at the end.
So string like "2.2.5\n" passes the validation.

Of course nobody types the version number like that.

@javiereguiluz
Copy link
Member

@kenjis a human won't type the version as 2.2.5\n, but beware that this tool could be used inside an automated command and then this trailing \n character could be indeed wrongly passed inside the version number.

@fivestar
Copy link
Contributor Author

@stof A regex has already been fixed. Anything else?

@kenjis
Copy link

kenjis commented Oct 21, 2014

@javiereguiluz Thank you for your comment.

I think 2.2.5\n is not valid version number. So we should use \z instead of $ ?

@fivestar
Copy link
Contributor Author

@kenjis Indeed, I also think \z is valid than $ whether or not multiline because it doesn't match \n.
However, @stof mentioned the consistency, so I think this PR is enough.

(英語かけてるかわからないので日本語で書いておきますが、\n にマッチしたところでたいした問題ではないので、気持ちもわかるんですが、一貫性を優先してこれでよいかと思っています。)

@stof
Copy link
Member

stof commented Oct 21, 2014

Thanks for fixing this bug @fivestar.

@stof stof closed this in ecad998 Oct 21, 2014
@fivestar fivestar deleted the feature/version-full-matching branch October 21, 2014 08:57
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants