[issue1462525] URI parsing library

vincent kraeutler report at bugs.python.org
Tue Nov 20 19:57:05 CET 2007

vincent kraeutler added the comment:

Quite like urlparse, uriparse does not fail on input which does not
represent valid URI's. At least not early or reliably enough.
Specifically, I noticed that urisplit does not fail on input strings
with a missing scheme, such as "foo.com/bar". 

I see no (straightforward) solution to this problem, short of using a
proper parser library such as Haskell's Parsec (I unfortunately know of
no Python equivalent), but I thought I might want to report this issue

The following might work as a quick-fix: Replace

with something like:

    mm = re.match(regex, uri)
    sp = mm.span()
    if (-1 in sp) or (sp[1] - sp[0] != len(uri)):
        raise ValueError, "uri regex did not match complete input"
    p = mm.groups()

nosy: +vincentk

Tracker <report at bugs.python.org>

More information about the Python-bugs-list mailing list