Marshmallow: fields.Url ValidationError parsing internationalized domain name

Created on 10 Oct 2019  Â·  1Comment  Â·  Source: marshmallow-code/marshmallow

Description

The perfectly valid urls in the test case below are resolved correctly by most contemporary browsers (and – curiously – wget, but not curl), but do not pass marshmallows Url field validation. Which i think they should, because they do show up in real world data.

I'm not sure how to best approach the problem.

Test Case

"""Tests for marshmallow.validate"""
import pytest

from marshmallow import validate


@pytest.mark.parametrize(
    "valid_url",
    [
        "http://www.kunstkontor-nürnberg.de",
        "http://💩.la",
    ],
)
def test_url_absolute_valid(valid_url):
    validator = validate.URL(relative=False)
    assert validator(valid_url) == valid_url

Most helpful comment

We may want to consider using urllib.

https://docs.python.org/3/library/urllib.parse.html#module-urllib.parse

>All comments

We may want to consider using urllib.

https://docs.python.org/3/library/urllib.parse.html#module-urllib.parse

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Ovyerus picture Ovyerus  Â·  3Comments

j4k0bk picture j4k0bk  Â·  3Comments

manoadamro picture manoadamro  Â·  3Comments

DenisKuplyakov picture DenisKuplyakov  Â·  4Comments

jayennis22 picture jayennis22  Â·  4Comments