[6.x] Fix a regression caused by #32315#32388
Merged
Merged
Conversation
Contributor
|
@Werelds good catch, thanks for fixing the issue and sorry for causing trouble. |
Collaborator
|
This fix has now been released. |
Contributor
Author
|
Thanks @GrahamCampbell! @bsacharski took me a while to spot it as well. When I looked at the regex directly I didn't spot it, I eventually resorted to running a diff between your version and Symfony's version, with all protocols except https removed for comparison. That's when I finally spotted it. I think we all have a strong love/hate relationship with regular expressions :D |
bsacharski
referenced
this pull request
Apr 16, 2020
…32315) The regex used by url validation logic was previously derived from version 2.7.4 of Symfony Validator component. As it turns out, old regex had a bug where it wouldn't accept urls where domain was a hostname ending with a digit. As such, the urls like http://domain1/ would be considered as invalid. To fix this issue I've updated \Illuminate\Validation\Concerns\ValidatesAttributes::validateUrl method using regex derived from version 5.0.7 of the Symfony Validator component. To make sure that the fix works, new test cases were also added. Co-authored-by: Bartlomiej Sacharski <bartlomiej@cementownia.org>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This fixes a regression caused by #32315, in which the regular expression was updated based on Symfony's Validator, but in doing so percent signs were copied across incorrectly. As a result, some valid URLs are now being reported as invalid. An example URL would be
https://domain.com/path/%2528failed%2526?param=1#fragment; admittedly, this is wrongly encoded, but that is kind of the point, as it is not technically invalid. I've added this URL to the test too.Symfony runs their regular expression through
sprintf(), so the double-encoded percent signs (%%) come out of that as single ones (%).This PR rectifies that. I generated the updated regular expression by running the whole thing through
sprintf()like Symfony would've, but with Laravel's fixed set of protocols.I've set the target to 6.x as this is a clear bug fix that should go into 6.x and 7.x alike.