Allow full URLs in href tags for REPORT requests

Fixes #192
This commit is contained in:
Guillaume Ayoub 2014-08-05 15:42:39 +02:00
parent a5c5f2494f
commit 0822f99650

View File

@ -36,9 +36,10 @@ except ImportError:
# Manage Python2/3 different modules # Manage Python2/3 different modules
# pylint: disable=F0401,E0611 # pylint: disable=F0401,E0611
try: try:
from urllib.parse import unquote from urllib.parse import unquote, urlparse
except ImportError: except ImportError:
from urllib import unquote from urllib import unquote
from urlparse import urlparse
# pylint: enable=F0401,E0611 # pylint: enable=F0401,E0611
import re import re
@ -473,10 +474,11 @@ def report(path, xml_request, collection):
_tag("CR", "addressbook-multiget")): _tag("CR", "addressbook-multiget")):
# Read rfc4791-7.9 for info # Read rfc4791-7.9 for info
base_prefix = config.get("server", "base_prefix") base_prefix = config.get("server", "base_prefix")
hreferences = set( hreferences = set()
unquote(href_element.text)[len(base_prefix):] for href_element for href_element in root.findall(_tag("D", "href")):
in root.findall(_tag("D", "href")) href_path = unquote(urlparse(href_element.text).path)
if unquote(href_element.text).startswith(base_prefix)) if href_path.startswith(base_prefix):
hreferences.add(href_path[len(base_prefix):])
else: else:
hreferences = (path,) hreferences = (path,)
# TODO: handle other filters # TODO: handle other filters