JsonType url filter is incomplete #2555

Closed
dogawaf opened this Issue Nov 18, 2015 · 5 comments

Comments

Projects
None yet
2 participants
@dogawaf

dogawaf commented Nov 18, 2015

The filter urlin JsonType fails to validate correctly url with a query string like http://example.com?foo=bar.

Here is the actual regex used: /^(https?:\/\/)?([\da-z\.-]+)\.([a-z\.]{2,6})([\/\w \.-]*)*\/?$/.
I suggest to use php filter_var builtin function, with the flag FILTER_VALIDATE_URL.

What do you think?

@dogawaf

This comment has been minimized.

Show comment
Hide comment
@dogawaf

dogawaf Nov 19, 2015

It seems that filter_var and FILTER_VALIDATE_URL validate only absolute url. So we need a custom regex to validate both relative and absolute url.

dogawaf commented Nov 19, 2015

It seems that filter_var and FILTER_VALIDATE_URL validate only absolute url. So we need a custom regex to validate both relative and absolute url.

@DavertMik

This comment has been minimized.

Show comment
Hide comment
@DavertMik

DavertMik Nov 19, 2015

Member

Url is expected to be absolute in case of JSON response. At least I'd suppose it to be this way

Member

DavertMik commented Nov 19, 2015

Url is expected to be absolute in case of JSON response. At least I'd suppose it to be this way

@dogawaf

This comment has been minimized.

Show comment
Hide comment
@dogawaf

dogawaf Nov 19, 2015

I am good (for my testcases) to validate only with absolute url, but it would be a breaking change.

dogawaf commented Nov 19, 2015

I am good (for my testcases) to validate only with absolute url, but it would be a breaking change.

@DavertMik

This comment has been minimized.

Show comment
Hide comment
@DavertMik

DavertMik Nov 19, 2015

Member

...or a bug fixes :) Anyway, please add your change, I think it is ok. If anyone needs to validate relative url they can add their own filter :uri, for instance, and use it. Filters are really easy to add

Member

DavertMik commented Nov 19, 2015

...or a bug fixes :) Anyway, please add your change, I think it is ok. If anyone needs to validate relative url they can add their own filter :uri, for instance, and use it. Filters are really easy to add

@DavertMik DavertMik closed this in b3936fb Nov 26, 2015

@dogawaf

This comment has been minimized.

Show comment
Hide comment
@dogawaf

dogawaf Nov 27, 2015

Nice, you were faster than me :)

dogawaf commented Nov 27, 2015

Nice, you were faster than me :)

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