From 9f6d1b10ad5a9098a8f72157875ce97fc44bc423 Mon Sep 17 00:00:00 2001 From: Kegan Dougal Date: Wed, 5 Nov 2014 11:21:55 +0000 Subject: [PATCH] Be sure to urlencode/decode event types correctly in both the web client and HS. --- synapse/rest/room.py | 2 +- syweb/webclient/components/matrix/matrix-service.js | 4 ++-- syweb/webclient/test/unit/matrix-service.spec.js | 6 +++--- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/synapse/rest/room.py b/synapse/rest/room.py index ec0ce78fd..d97babea0 100644 --- a/synapse/rest/room.py +++ b/synapse/rest/room.py @@ -148,7 +148,7 @@ class RoomStateEventRestServlet(RestServlet): content = _parse_json(request) event = self.event_factory.create_event( - etype=event_type, + etype=urllib.unquote(event_type), content=content, room_id=urllib.unquote(room_id), user_id=user.to_string(), diff --git a/syweb/webclient/components/matrix/matrix-service.js b/syweb/webclient/components/matrix/matrix-service.js index 5b63fb4a3..e1e5b88b3 100644 --- a/syweb/webclient/components/matrix/matrix-service.js +++ b/syweb/webclient/components/matrix/matrix-service.js @@ -375,9 +375,9 @@ angular.module('matrixService', []) sendStateEvent: function(room_id, eventType, content, state_key) { - var path = "/rooms/$room_id/state/"+eventType; + var path = "/rooms/$room_id/state/"+ encodeURIComponent(eventType); if (state_key !== undefined) { - path += "/" + state_key; + path += "/" + encodeURIComponent(state_key); } room_id = encodeURIComponent(room_id); path = path.replace("$room_id", room_id); diff --git a/syweb/webclient/test/unit/matrix-service.spec.js b/syweb/webclient/test/unit/matrix-service.spec.js index 95a43057c..b54163a64 100644 --- a/syweb/webclient/test/unit/matrix-service.spec.js +++ b/syweb/webclient/test/unit/matrix-service.spec.js @@ -238,7 +238,7 @@ describe('MatrixService', function() { homeserver: "http://example.com" }); var roomId = "!fh38hfwfwef:example.com"; - var eventType = "com.example.events.test"; + var eventType = "com.example.events.test:special@characters"; var content = { testing: "1 2 3" }; @@ -262,11 +262,11 @@ describe('MatrixService', function() { homeserver: "http://example.com" }); var roomId = "!fh38hfwfwef:example.com"; - var eventType = "com.example.events.test"; + var eventType = "com.example.events.test:special@characters"; var content = { testing: "1 2 3" }; - var stateKey = "version1"; + var stateKey = "version:1"; matrixService.sendStateEvent(roomId, eventType, content, stateKey).then( function(response) { expect(response.data).toEqual({});