Esempio n. 1
0
    def sanitize_path(url):
        parts = urlparse.urlsplit(unquote(url))

        if parts.hostname is None or parts.hostname == "":
            raise UrlValidationException

        return url
Esempio n. 2
0
    def sanitize_scheme(url):
        if urlparse.urlsplit(unquote(url)).scheme not in VALID_SCHEMES:
            if level in ("validate", "filter"):
                parts = urlparse.urlsplit(url)
                url = urlparse.urlunsplit(("", parts.netloc, parts.path, parts.query, parts.fragment))
                return urlparse.urljoin("http:", re.sub("^/*", "//", url))
            else:
                raise UrlValidationException

        return url