Skip to content
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

Unable to add urls with complex query string #28

Closed
davidolrik opened this issue May 14, 2019 · 4 comments
Closed

Unable to add urls with complex query string #28

davidolrik opened this issue May 14, 2019 · 4 comments
Assignees
Labels
bug Something isn't working

Comments

@davidolrik
Copy link

If I try to shorten any url with a query string I get the following error: The url format is invalid.

@davidolrik davidolrik added the bug Something isn't working label May 14, 2019
@optiroot
Copy link
Member

Thank you for opening this issue!
Mmh... I can't replicate this.
Validation errors were solved in the commit Updated Regex to allow ?, _ - and =
Maybe you need to update UrlHum from the repo?

@davidolrik
Copy link
Author

I'm running on latest, and fixed it by removeing the trailing $ from this rule in app/Http/Requests/ShortUrl.php

- 'url' => 'required|max:500|regex:/^(https?:\/\/)?([\da-z\.-]+)\.([a-z\.]{2,6})([\_\-\?\=\/\w \.-]*)*\/?$/',
+ 'url' => 'required|max:500|regex:/^(https?:\/\/)?([\da-z\.-]+)\.([a-z\.]{2,6})([\_\-\?\=\/\w \.-]*)*\/?/',

@davidolrik
Copy link
Author

davidolrik commented May 14, 2019

You should allow pretty much any character in the query string, stuff like | and & are definitely missing.

A better approach would be to use filter_var($url, FILTER_VALIDATE_URL) which validates the url according to rfc2396.

@davidolrik davidolrik changed the title Unable to add urls with query string Unable to add urls with complex query string May 14, 2019
@optiroot
Copy link
Member

With my push GitHub automatically closed the issue, sorry.

In the end I decided to use default Laravel url validation, which uses FILTER_VALIDATE_URL anyway!
Thank you for your issue. It was very helpful.
Going to close this again 😄

@optiroot optiroot reopened this May 14, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants