How to use the wsgidav.compat.quote function in WsgiDAV

To help you get started, we’ve selected a few WsgiDAV examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github mar10 / wsgidav / tests / test_wsgidav_app.py View on Github external
def unicode_to_url(s):
            # TODO: Py3: Is this the correct way?
            return compat.quote(s.encode("utf8"))
github mar10 / wsgidav / wsgidav / prop_man / couch_property_manager.py View on Github external
_logger.debug(
            "write_property(%s, %s, dry_run=%s):\n\t%s"
            % (norm_url, name, dry_run, property_value)
        )
        if dry_run:
            return  # TODO: can we check anything here?

        doc = self._find(norm_url)
        if doc:
            doc["properties"][name] = property_value
        else:
            doc = {
                "_id": uuid4().hex,  # Documentation suggests to set the id
                "url": norm_url,
                "title": compat.quote(norm_url),
                "type": "properties",
                "properties": {name: property_value},
            }
        self.db.save(doc)
github mar10 / wsgidav / wsgidav / util.py View on Github external
if environ.get("HTTP_HOST"):
        url += environ["HTTP_HOST"]
    else:
        url += environ["SERVER_NAME"]

        if environ["wsgi.url_scheme"] == "https":
            if environ["SERVER_PORT"] != "443":
                url += ":" + environ["SERVER_PORT"]
        else:
            if environ["SERVER_PORT"] != "80":
                url += ":" + environ["SERVER_PORT"]

    url += compat.quote(environ.get("SCRIPT_NAME", ""))

    if localUri is None:
        url += compat.quote(environ.get("PATH_INFO", ""))
        if environ.get("QUERY_STRING"):
            url += "?" + environ["QUERY_STRING"]
    else:
        url += localUri  # TODO: quote?
    return url
github mar10 / wsgidav / wsgidav / samples / virtual_dav_provider.py View on Github external
def get_ref_url(self):
        refPath = "/by_key/%s/%s" % (self.data["key"], os.path.basename(self.file_path))
        return compat.quote(self.provider.share_path + refPath)
github mar10 / wsgidav / wsgidav / dav_provider.py View on Github external
Byte string, UTF-8 encoded, quoted.
        Starts with a '/'. Collections also have a trailing '/'.

        This is basically the same as get_preferred_path, but deals with
        'virtual locations' as well.

        e.g. '/a/b' == '/A/b' == '/bykey/123' == '/byguid/abc532'

        get_ref_url() returns the same value for all these URLs, so it can be
        used as a key for locking and persistence storage.

        DAV providers that allow virtual-mappings must override this method.

        See also comments in DEVELOPERS.txt glossary.
        """
        return compat.quote(self.provider.share_path + self.get_preferred_path())
github mar10 / wsgidav / wsgidav / prop_man / mongo_property_manager.py View on Github external
):
        assert norm_url and norm_url.startswith("/")
        assert name
        assert property_value is not None
        assert name not in HIDDEN_KEYS, "MongoDB key is protected: '%s'" % name

        _logger.debug(
            "write_property(%s, %s, dry_run=%s):\n\t%s"
            % (norm_url, name, dry_run, property_value)
        )
        if dry_run:
            return  # TODO: can we check anything here?

        doc = self.collection.find_one({"_url": norm_url})
        if not doc:
            doc = {"_url": norm_url, "_title": compat.quote(norm_url)}
        doc[encode_mongo_key(name)] = property_value
        self.collection.save(doc)
github mar10 / wsgidav / wsgidav / prop_man / couch_property_manager.py View on Github external
def copy_properties(self, srcUrl, destUrl, environ=None):
        doc = self._find(srcUrl)
        if not doc:
            _logger.debug(
                "copy_properties(%s, %s): src has no properties" % (srcUrl, destUrl)
            )
            return
        _logger.debug("copy_properties(%s, %s)" % (srcUrl, destUrl))
        assert not self._find(destUrl)
        doc2 = {
            "_id": uuid4().hex,
            "url": destUrl,
            "title": compat.quote(destUrl),
            "type": "properties",
            "properties": doc["properties"],
        }
        self.db.save(doc2)