Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
@pytest.fixture(params=[_PyUnquoter, _Unquoter], ids=["py_unquoter", "c_unquoter"])
def unquoter(request):
return request.param
# URI-reference = URI / relative-ref
# relative-ref = relative-part [ "?" query ] [ "#" fragment ]
# relative-part = "//" authority path-abempty
# / path-absolute
# / path-noscheme
# / path-empty
# absolute-URI = scheme ":" hier-part [ "?" query ]
__slots__ = ("_cache", "_val")
_QUOTER = _Quoter()
_PATH_QUOTER = _Quoter(safe="@:", protected="/+")
_QUERY_QUOTER = _Quoter(safe="?/:@", protected="=+&;", qs=True)
_QUERY_PART_QUOTER = _Quoter(safe="?/:@", qs=True)
_FRAGMENT_QUOTER = _Quoter(safe="?/:@")
_UNQUOTER = _Unquoter()
_PATH_UNQUOTER = _Unquoter(unsafe="+")
_QS_UNQUOTER = _Unquoter(qs=True)
def __new__(cls, val="", *, encoded=False, strict=None):
if strict is not None: # pragma: no cover
warnings.warn("strict parameter is ignored")
if type(val) is cls:
return val
if type(val) is str:
val = urlsplit(val)
elif type(val) is SplitResult:
if not encoded:
raise ValueError("Cannot apply decoding to SplitResult")
elif isinstance(val, str):
val = urlsplit(str(val))
else:
# relative-part = "//" authority path-abempty
# / path-absolute
# / path-noscheme
# / path-empty
# absolute-URI = scheme ":" hier-part [ "?" query ]
__slots__ = ("_cache", "_val")
_QUOTER = _Quoter()
_PATH_QUOTER = _Quoter(safe="@:", protected="/+")
_QUERY_QUOTER = _Quoter(safe="?/:@", protected="=+&;", qs=True)
_QUERY_PART_QUOTER = _Quoter(safe="?/:@", qs=True)
_FRAGMENT_QUOTER = _Quoter(safe="?/:@")
_UNQUOTER = _Unquoter()
_PATH_UNQUOTER = _Unquoter(unsafe="+")
_QS_UNQUOTER = _Unquoter(qs=True)
def __new__(cls, val="", *, encoded=False, strict=None):
if strict is not None: # pragma: no cover
warnings.warn("strict parameter is ignored")
if type(val) is cls:
return val
if type(val) is str:
val = urlsplit(val)
elif type(val) is SplitResult:
if not encoded:
raise ValueError("Cannot apply decoding to SplitResult")
elif isinstance(val, str):
val = urlsplit(str(val))
else:
raise TypeError("Constructor parameter should be str")
# relative-ref = relative-part [ "?" query ] [ "#" fragment ]
# relative-part = "//" authority path-abempty
# / path-absolute
# / path-noscheme
# / path-empty
# absolute-URI = scheme ":" hier-part [ "?" query ]
__slots__ = ("_cache", "_val")
_QUOTER = _Quoter()
_PATH_QUOTER = _Quoter(safe="@:", protected="/+")
_QUERY_QUOTER = _Quoter(safe="?/:@", protected="=+&;", qs=True)
_QUERY_PART_QUOTER = _Quoter(safe="?/:@", qs=True)
_FRAGMENT_QUOTER = _Quoter(safe="?/:@")
_UNQUOTER = _Unquoter()
_PATH_UNQUOTER = _Unquoter(unsafe="+")
_QS_UNQUOTER = _Unquoter(qs=True)
def __new__(cls, val="", *, encoded=False, strict=None):
if strict is not None: # pragma: no cover
warnings.warn("strict parameter is ignored")
if type(val) is cls:
return val
if type(val) is str:
val = urlsplit(val)
elif type(val) is SplitResult:
if not encoded:
raise ValueError("Cannot apply decoding to SplitResult")
elif isinstance(val, str):
val = urlsplit(str(val))
else:
raise TypeError("Constructor parameter should be str")