diff options
author | Emmanuel ROHEE <erohee@amdocs.com> | 2014-09-24 12:22:40 +0200 |
---|---|---|
committer | Emmanuel ROHEE <erohee@amdocs.com> | 2014-09-24 12:22:40 +0200 |
commit | 6f5970a2e100f48742e925570a2f2fad1b401c40 (patch) | |
tree | 85a648a98fcc571c413c0e26b70597da85382444 /webclient/components | |
parent | State data now provides up-to-date users displaynames. So use it first. (diff) | |
download | synapse-6f5970a2e100f48742e925570a2f2fad1b401c40.tar.xz |
Added hasOwnProperty tests when required to be robust to random properties added to he Object prototype
Diffstat (limited to 'webclient/components')
-rw-r--r-- | webclient/components/matrix/event-handler-service.js | 5 | ||||
-rw-r--r-- | webclient/components/matrix/matrix-filter.js | 2 |
2 files changed, 6 insertions, 1 deletions
diff --git a/webclient/components/matrix/event-handler-service.js b/webclient/components/matrix/event-handler-service.js index 770ac938ca..d8deb0ac8b 100644 --- a/webclient/components/matrix/event-handler-service.js +++ b/webclient/components/matrix/event-handler-service.js @@ -115,8 +115,9 @@ function(matrixService, $rootScope, $q, $timeout, mPresence) { if (room) { // we got an existing room object from initialsync, seemingly. // Report all other metadata of the room object (membership, inviter, visibility, ...) - // XXX: do we *REALLY* want to iterate over *EVERY* field in the object, including all its methods etc? -- Matthew for (var field in room) { + if (!room.hasOwnProperty(field)) continue; + if (-1 === ["room_id", "messages", "state"].indexOf(field)) { // why indexOf - why not ===? --Matthew $rootScope.events.rooms[room_id][field] = room[field]; } @@ -517,6 +518,8 @@ function(matrixService, $rootScope, $q, $timeout, mPresence) { memberCount = 0; for (var i in room.members) { + if (!room.members.hasOwnProperty(i)) continue; + var member = room.members[i]; if ("join" === member.membership) { diff --git a/webclient/components/matrix/matrix-filter.js b/webclient/components/matrix/matrix-filter.js index 96642a8720..c27746b380 100644 --- a/webclient/components/matrix/matrix-filter.js +++ b/webclient/components/matrix/matrix-filter.js @@ -45,6 +45,8 @@ angular.module('matrixFilter', []) // Limit the room renaming to 1:1 room if (2 === Object.keys(room.members).length) { for (var i in room.members) { + if (!room.members.hasOwnProperty(i)) continue; + var member = room.members[i]; if (member.state_key !== user_id) { roomName = eventHandlerService.getUserDisplayName(room_id, member.state_key); |