forked from MirrorHub/synapse
Merge pull request #3108 from NotAFile/py3-six-urlparse
Use six.moves.urlparse
This commit is contained in:
commit
9e2601f830
8 changed files with 20 additions and 21 deletions
|
@ -17,11 +17,11 @@ from ._base import Config, ConfigError
|
||||||
from synapse.appservice import ApplicationService
|
from synapse.appservice import ApplicationService
|
||||||
from synapse.types import UserID
|
from synapse.types import UserID
|
||||||
|
|
||||||
import urllib
|
|
||||||
import yaml
|
import yaml
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
from six import string_types
|
from six import string_types
|
||||||
|
from six.moves.urllib import parse as urlparse
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
@ -105,7 +105,7 @@ def _load_appservice(hostname, as_info, config_filename):
|
||||||
)
|
)
|
||||||
|
|
||||||
localpart = as_info["sender_localpart"]
|
localpart = as_info["sender_localpart"]
|
||||||
if urllib.quote(localpart) != localpart:
|
if urlparse.quote(localpart) != localpart:
|
||||||
raise ValueError(
|
raise ValueError(
|
||||||
"sender_localpart needs characters which are not URL encoded."
|
"sender_localpart needs characters which are not URL encoded."
|
||||||
)
|
)
|
||||||
|
|
|
@ -41,8 +41,7 @@ import logging
|
||||||
import random
|
import random
|
||||||
import sys
|
import sys
|
||||||
import urllib
|
import urllib
|
||||||
import urlparse
|
from six.moves.urllib import parse as urlparse
|
||||||
|
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
outbound_logger = logging.getLogger("synapse.http.outbound")
|
outbound_logger = logging.getLogger("synapse.http.outbound")
|
||||||
|
|
|
@ -25,7 +25,7 @@ from .base import ClientV1RestServlet, client_path_patterns
|
||||||
|
|
||||||
import simplejson as json
|
import simplejson as json
|
||||||
import urllib
|
import urllib
|
||||||
import urlparse
|
from six.moves.urllib import parse as urlparse
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
from saml2 import BINDING_HTTP_POST
|
from saml2 import BINDING_HTTP_POST
|
||||||
|
|
|
@ -28,8 +28,9 @@ from synapse.http.servlet import (
|
||||||
parse_json_object_from_request, parse_string, parse_integer
|
parse_json_object_from_request, parse_string, parse_integer
|
||||||
)
|
)
|
||||||
|
|
||||||
|
from six.moves.urllib import parse as urlparse
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
import urllib
|
|
||||||
import simplejson as json
|
import simplejson as json
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
@ -433,7 +434,7 @@ class RoomMessageListRestServlet(ClientV1RestServlet):
|
||||||
as_client_event = "raw" not in request.args
|
as_client_event = "raw" not in request.args
|
||||||
filter_bytes = request.args.get("filter", None)
|
filter_bytes = request.args.get("filter", None)
|
||||||
if filter_bytes:
|
if filter_bytes:
|
||||||
filter_json = urllib.unquote(filter_bytes[-1]).decode("UTF-8")
|
filter_json = urlparse.unquote(filter_bytes[-1]).decode("UTF-8")
|
||||||
event_filter = Filter(json.loads(filter_json))
|
event_filter = Filter(json.loads(filter_json))
|
||||||
else:
|
else:
|
||||||
event_filter = None
|
event_filter = None
|
||||||
|
@ -718,8 +719,8 @@ class RoomTypingRestServlet(ClientV1RestServlet):
|
||||||
def on_PUT(self, request, room_id, user_id):
|
def on_PUT(self, request, room_id, user_id):
|
||||||
requester = yield self.auth.get_user_by_req(request)
|
requester = yield self.auth.get_user_by_req(request)
|
||||||
|
|
||||||
room_id = urllib.unquote(room_id)
|
room_id = urlparse.unquote(room_id)
|
||||||
target_user = UserID.from_string(urllib.unquote(user_id))
|
target_user = UserID.from_string(urlparse.unquote(user_id))
|
||||||
|
|
||||||
content = parse_json_object_from_request(request)
|
content = parse_json_object_from_request(request)
|
||||||
|
|
||||||
|
|
|
@ -28,7 +28,7 @@ import os
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
import urllib
|
import urllib
|
||||||
import urlparse
|
from six.moves.urllib import parse as urlparse
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
|
@ -47,7 +47,7 @@ import shutil
|
||||||
|
|
||||||
import cgi
|
import cgi
|
||||||
import logging
|
import logging
|
||||||
import urlparse
|
from six.moves.urllib import parse as urlparse
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
|
@ -24,7 +24,7 @@ from synapse.api.constants import Membership
|
||||||
from synapse.types import UserID
|
from synapse.types import UserID
|
||||||
|
|
||||||
import json
|
import json
|
||||||
import urllib
|
from six.moves.urllib import parse as urlparse
|
||||||
|
|
||||||
from ....utils import MockHttpResource, setup_test_homeserver
|
from ....utils import MockHttpResource, setup_test_homeserver
|
||||||
from .utils import RestTestCase
|
from .utils import RestTestCase
|
||||||
|
@ -766,7 +766,7 @@ class RoomMemberStateTestCase(RestTestCase):
|
||||||
@defer.inlineCallbacks
|
@defer.inlineCallbacks
|
||||||
def test_rooms_members_self(self):
|
def test_rooms_members_self(self):
|
||||||
path = "/rooms/%s/state/m.room.member/%s" % (
|
path = "/rooms/%s/state/m.room.member/%s" % (
|
||||||
urllib.quote(self.room_id), self.user_id
|
urlparse.quote(self.room_id), self.user_id
|
||||||
)
|
)
|
||||||
|
|
||||||
# valid join message (NOOP since we made the room)
|
# valid join message (NOOP since we made the room)
|
||||||
|
@ -786,7 +786,7 @@ class RoomMemberStateTestCase(RestTestCase):
|
||||||
def test_rooms_members_other(self):
|
def test_rooms_members_other(self):
|
||||||
self.other_id = "@zzsid1:red"
|
self.other_id = "@zzsid1:red"
|
||||||
path = "/rooms/%s/state/m.room.member/%s" % (
|
path = "/rooms/%s/state/m.room.member/%s" % (
|
||||||
urllib.quote(self.room_id), self.other_id
|
urlparse.quote(self.room_id), self.other_id
|
||||||
)
|
)
|
||||||
|
|
||||||
# valid invite message
|
# valid invite message
|
||||||
|
@ -802,7 +802,7 @@ class RoomMemberStateTestCase(RestTestCase):
|
||||||
def test_rooms_members_other_custom_keys(self):
|
def test_rooms_members_other_custom_keys(self):
|
||||||
self.other_id = "@zzsid1:red"
|
self.other_id = "@zzsid1:red"
|
||||||
path = "/rooms/%s/state/m.room.member/%s" % (
|
path = "/rooms/%s/state/m.room.member/%s" % (
|
||||||
urllib.quote(self.room_id), self.other_id
|
urlparse.quote(self.room_id), self.other_id
|
||||||
)
|
)
|
||||||
|
|
||||||
# valid invite message with custom key
|
# valid invite message with custom key
|
||||||
|
@ -859,7 +859,7 @@ class RoomMessagesTestCase(RestTestCase):
|
||||||
@defer.inlineCallbacks
|
@defer.inlineCallbacks
|
||||||
def test_invalid_puts(self):
|
def test_invalid_puts(self):
|
||||||
path = "/rooms/%s/send/m.room.message/mid1" % (
|
path = "/rooms/%s/send/m.room.message/mid1" % (
|
||||||
urllib.quote(self.room_id))
|
urlparse.quote(self.room_id))
|
||||||
# missing keys or invalid json
|
# missing keys or invalid json
|
||||||
(code, response) = yield self.mock_resource.trigger(
|
(code, response) = yield self.mock_resource.trigger(
|
||||||
"PUT", path, '{}'
|
"PUT", path, '{}'
|
||||||
|
@ -894,7 +894,7 @@ class RoomMessagesTestCase(RestTestCase):
|
||||||
@defer.inlineCallbacks
|
@defer.inlineCallbacks
|
||||||
def test_rooms_messages_sent(self):
|
def test_rooms_messages_sent(self):
|
||||||
path = "/rooms/%s/send/m.room.message/mid1" % (
|
path = "/rooms/%s/send/m.room.message/mid1" % (
|
||||||
urllib.quote(self.room_id))
|
urlparse.quote(self.room_id))
|
||||||
|
|
||||||
content = '{"body":"test","msgtype":{"type":"a"}}'
|
content = '{"body":"test","msgtype":{"type":"a"}}'
|
||||||
(code, response) = yield self.mock_resource.trigger("PUT", path, content)
|
(code, response) = yield self.mock_resource.trigger("PUT", path, content)
|
||||||
|
@ -911,7 +911,7 @@ class RoomMessagesTestCase(RestTestCase):
|
||||||
|
|
||||||
# m.text message type
|
# m.text message type
|
||||||
path = "/rooms/%s/send/m.room.message/mid2" % (
|
path = "/rooms/%s/send/m.room.message/mid2" % (
|
||||||
urllib.quote(self.room_id))
|
urlparse.quote(self.room_id))
|
||||||
content = '{"body":"test2","msgtype":"m.text"}'
|
content = '{"body":"test2","msgtype":"m.text"}'
|
||||||
(code, response) = yield self.mock_resource.trigger("PUT", path, content)
|
(code, response) = yield self.mock_resource.trigger("PUT", path, content)
|
||||||
self.assertEquals(200, code, msg=str(response))
|
self.assertEquals(200, code, msg=str(response))
|
||||||
|
|
|
@ -15,8 +15,7 @@
|
||||||
|
|
||||||
import hashlib
|
import hashlib
|
||||||
from inspect import getcallargs
|
from inspect import getcallargs
|
||||||
import urllib
|
from six.moves.urllib import parse as urlparse
|
||||||
import urlparse
|
|
||||||
|
|
||||||
from mock import Mock, patch
|
from mock import Mock, patch
|
||||||
from twisted.internet import defer, reactor
|
from twisted.internet import defer, reactor
|
||||||
|
@ -238,7 +237,7 @@ class MockHttpResource(HttpServer):
|
||||||
if matcher:
|
if matcher:
|
||||||
try:
|
try:
|
||||||
args = [
|
args = [
|
||||||
urllib.unquote(u).decode("UTF-8")
|
urlparse.unquote(u).decode("UTF-8")
|
||||||
for u in matcher.groups()
|
for u in matcher.groups()
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue