Be sure to urlencode/decode event types correctly in both the web client and HS.

This commit is contained in:
Kegan Dougal 2014-11-05 11:21:55 +00:00
parent a2aafeb959
commit 9f6d1b10ad
3 changed files with 6 additions and 6 deletions

View file

@ -148,7 +148,7 @@ class RoomStateEventRestServlet(RestServlet):
content = _parse_json(request) content = _parse_json(request)
event = self.event_factory.create_event( event = self.event_factory.create_event(
etype=event_type, etype=urllib.unquote(event_type),
content=content, content=content,
room_id=urllib.unquote(room_id), room_id=urllib.unquote(room_id),
user_id=user.to_string(), user_id=user.to_string(),

View file

@ -375,9 +375,9 @@ angular.module('matrixService', [])
sendStateEvent: function(room_id, eventType, content, state_key) { 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) { if (state_key !== undefined) {
path += "/" + state_key; path += "/" + encodeURIComponent(state_key);
} }
room_id = encodeURIComponent(room_id); room_id = encodeURIComponent(room_id);
path = path.replace("$room_id", room_id); path = path.replace("$room_id", room_id);

View file

@ -238,7 +238,7 @@ describe('MatrixService', function() {
homeserver: "http://example.com" homeserver: "http://example.com"
}); });
var roomId = "!fh38hfwfwef:example.com"; var roomId = "!fh38hfwfwef:example.com";
var eventType = "com.example.events.test"; var eventType = "com.example.events.test:special@characters";
var content = { var content = {
testing: "1 2 3" testing: "1 2 3"
}; };
@ -262,11 +262,11 @@ describe('MatrixService', function() {
homeserver: "http://example.com" homeserver: "http://example.com"
}); });
var roomId = "!fh38hfwfwef:example.com"; var roomId = "!fh38hfwfwef:example.com";
var eventType = "com.example.events.test"; var eventType = "com.example.events.test:special@characters";
var content = { var content = {
testing: "1 2 3" testing: "1 2 3"
}; };
var stateKey = "version1"; var stateKey = "version:1";
matrixService.sendStateEvent(roomId, eventType, content, stateKey).then( matrixService.sendStateEvent(roomId, eventType, content, stateKey).then(
function(response) { function(response) {
expect(response.data).toEqual({}); expect(response.data).toEqual({});