python-validators / validators

Python Data Validation for Humans™.
MIT License
977 stars 155 forks source link

Fix fragment check #305

Closed darkdragon-001 closed 1 year ago

darkdragon-001 commented 1 year ago

Fragments should allow a specific set of characters (see https://stackoverflow.com/a/26119120/3779655).

See https://github.com/python-validators/validators/issues/299#issuecomment-1746084781

yozachar commented 1 year ago

@darkdragon-001, looks like that regex didn't hash out properly, can you fix it?


run log

=========================== short test summary info ============================
FAILED tests/test_url.py::test_returns_true_on_valid_url[http://foo.com/blah_(wikipedia)#cite-1] - AssertionError: assert ValidationError(func=url, args={'reason': 'bad character range @-. at position 16', 'value': 'http://foo.com/blah_(wikipedia)#cite-1'})
 +  where ValidationError(func=url, args={'reason': 'bad character range @-. at position 16', 'value': 'http://foo.com/blah_(wikipedia)#cite-1'}) = url('http://foo.com/blah_(wikipedia)#cite-1')
FAILED tests/test_url.py::test_returns_true_on_valid_url[http://foo.com/blah_(wikipedia)_blah#cite-1] - AssertionError: assert ValidationError(func=url, args={'reason': 'bad character range @-. at position 16', 'value': 'http://foo.com/blah_(wikipedia)_blah#cite-1'})
 +  where ValidationError(func=url, args={'reason': 'bad character range @-. at position 16', 'value': 'http://foo.com/blah_(wikipedia)_blah#cite-1'}) = url('http://foo.com/blah_(wikipedia)_blah#cite-1')
FAILED tests/test_url.py::test_returns_true_on_valid_url[http://code.google.com/events/#&product=browser] - AssertionError: assert ValidationError(func=url, args={'reason': 'bad character range @-. at position 16', 'value': 'http://code.google.com/events/#&product=browser'})
 +  where ValidationError(func=url, args={'reason': 'bad character range @-. at position 16', 'value': 'http://code.google.com/events/#&product=browser'}) = url('http://code.google.com/events/#&product=browser')
FAILED tests/test_url.py::test_returns_true_on_valid_url[https://exchange.jetswap.finance/#/swap] - AssertionError: assert ValidationError(func=url, args={'reason': 'bad character range @-. at position 16', 'value': 'https://exchange.jetswap.finance/#/swap'})
 +  where ValidationError(func=url, args={'reason': 'bad character range @-. at position 16', 'value': 'https://exchange.jetswap.finance/#/swap'}) = url('https://exchange.jetswap.finance/#/swap')
FAILED tests/test_url.py::test_returns_true_on_valid_url[https://www.foo.com/bar#/baz/test] - AssertionError: assert ValidationError(func=url, args={'reason': 'bad character range @-. at position 16', 'value': 'https://www.foo.com/bar#/baz/test'})
 +  where ValidationError(func=url, args={'reason': 'bad character range @-. at position 16', 'value': 'https://www.foo.com/bar#/baz/test'}) = url('https://www.foo.com/bar#/baz/test')
FAILED tests/test_url.py::test_returns_true_on_valid_url[https://matrix.to/#/!BSqRHgvCtIsGittkBG:talk.puri.sm/$1551464398853539kMJNP:matrix.org?via=talk.puri.sm&via=matrix.org&via=disroot.org] - AssertionError: assert ValidationError(func=url, args={'reason': 'bad character range @-. at position 16', 'value': 'https://matrix.to/#/!BSqRHgvCtIsGittkBG:talk.puri.sm/$1551464398853539kMJNP:matrix.org?via=talk.puri.sm&via=matrix.org&via=disroot.org'})
 +  where ValidationError(func=url, args={'reason': 'bad character range @-. at position 16', 'value': 'https://matrix.to/#/!BSqRHgvCtIsGittkBG:talk.puri.sm/$1551464398853539kMJNP:matrix.org?via=talk.puri.sm&via=matrix.org&via=disroot.org'}) = url('https://matrix.to/#/!BSqRHgvCtIsGittkBG:talk.puri.sm/$1551464398853539kMJNP:matrix.org?via=talk.puri.sm&via=matrix.org&via=disroot.org')
======================== 6 failed, 555 passed in 0.87s =========================