You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Using wtforms.validators.URL to validate URL with query parameters incorrectly returns False.
importwtformsclassURLForm(wtforms.Form):
url=wtforms.StringField('MyLink', validators=[wtforms.validators.URL()])
URLForm(url='https://example.com').validate()
# -> TrueURLForm(url='https://example.com?this=fails').validate()
# -> False, but this should be True as it's a valid URL
Seems like this is because the regex used in URL validation incorrectly includes query parameters to the hostname, and then HostnameValidation fails.
Using
wtforms.validators.URL
to validate URL with query parameters incorrectly returnsFalse
.Seems like this is because the regex used in URL validation incorrectly includes query parameters to the hostname, and then
HostnameValidation
fails.https://github.com/wtforms/wtforms/blob/master/src/wtforms/validators.py#L498
Instead, the regex should separate hostname and query parameters, and only use the actual hostname for
HostnameValidation
.I'll cook up a PR to fix this later this week, unless someone is faster than that :)
The text was updated successfully, but these errors were encountered: