Skip to content

[7.x] Updated ValidatesAttributes::validateUrl to use Symfony/Validator 5.1 regex#32302

Closed
bsacharski wants to merge 85 commits intolaravel:7.xfrom
bsacharski:validateurl-symfony-5-1
Closed

[7.x] Updated ValidatesAttributes::validateUrl to use Symfony/Validator 5.1 regex#32302
bsacharski wants to merge 85 commits intolaravel:7.xfrom
bsacharski:validateurl-symfony-5-1

Conversation

@bsacharski
Copy link
Copy Markdown
Contributor

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.1.0 of the Symfony Validator component.
To make sure that the fix works, new test cases were also added.

taylorotwell and others added 13 commits April 2, 2020 10:47
This PR adds support for a new php artisan schema:dump command which uses mysqldump or pgdump to dump the current state of your schema to a database/schema/{connection}-schema.mysql file.

When this file exists and php artisan migrate or php artisan migrate:fresh is run AND no migrations have run against the database yet (migrations table is empty), this schema file will be loaded into the database first and then any outstanding migrations will be run. This means that effectively this schema file would typically only ever be used during local development or during CI testing. In production, you would typically already have migrations that have run in the past so this schema file would never be triggered.

Once the schema file is created, any or all of your existing migrations my be deleted as long as they have already run against your production environment. They are no longer needed during local development since the schema file exists. For convenience, a --prune flag has been added to the schema:dump command to delete your existing migrations after dumping the schema.

This new feature solves two problems. First, it relieves developers from having a huge migrations directory full of files they no longer need. Second, loading a single schema file is quicker than running hundreds of migrations for each test class in your applications, so your tests can run much faster when using a schema.

/**
* @dataProvider validUrls
* @group WIP
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

?


/*
* This pattern is derived from Symfony\Component\Validator\Constraints\UrlValidator (2.7.4).
* This pattern is derived from Symfony Validator component, file Constraints/UrlValidator.php (5.1.0).
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please leave this as the class name.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no 5.1.0 version, also?


/*
* This pattern is derived from Symfony\Component\Validator\Constraints\UrlValidator (2.7.4).
* This pattern is derived from Symfony Validator component, file Constraints/UrlValidator.php (5.1.0).
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no 5.1.0 version, also?

jasonmccreary and others added 10 commits April 9, 2020 07:37
* Add isEmpty() method to HtmlString

* Update HtmlString.php

* Update HtmlString.php

Co-authored-by: Taylor Otwell <taylor@laravel.com>
….7 regex

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.
@bsacharski bsacharski closed this Apr 9, 2020
@bsacharski bsacharski deleted the validateurl-symfony-5-1 branch April 9, 2020 05:43
@bsacharski
Copy link
Copy Markdown
Contributor Author

@GrahamCampbell thanks for review. I guess this is why I shouldn't code before going to bed and few minutes after waking up (rebased the master onto 7.x-derived branch...) 😄

Created new PR (with properly used & referenced STABLE Symfony version) #32307

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants