Validate that URL previews are explicitly enabled/disabled

Otherwise `!null` ends up being "true", therefore forcing URL previews on for everyone.

Fixes https://github.com/vector-im/riot-web/issues/5607

Signed-off-by: Travis Ralston <travpc@gmail.com>
This commit is contained in:
Travis Ralston 2017-11-15 19:22:30 -07:00
parent 022e40a127
commit cf8ff6aed3
3 changed files with 9 additions and 0 deletions

View file

@ -26,6 +26,9 @@ export default class AccountSettingHandler extends SettingsHandler {
// Special case URL previews // Special case URL previews
if (settingName === "urlPreviewsEnabled") { if (settingName === "urlPreviewsEnabled") {
const content = this._getSettings("org.matrix.preview_urls"); const content = this._getSettings("org.matrix.preview_urls");
// Check to make sure that we actually got a boolean
if (typeof(content['disable']) !== "boolean") return null;
return !content['disable']; return !content['disable'];
} }

View file

@ -25,6 +25,9 @@ export default class RoomAccountSettingsHandler extends SettingsHandler {
// Special case URL previews // Special case URL previews
if (settingName === "urlPreviewsEnabled") { if (settingName === "urlPreviewsEnabled") {
const content = this._getSettings(roomId, "org.matrix.room.preview_urls"); const content = this._getSettings(roomId, "org.matrix.room.preview_urls");
// Check to make sure that we actually got a boolean
if (typeof(content['disable']) !== "boolean") return null;
return !content['disable']; return !content['disable'];
} }

View file

@ -25,6 +25,9 @@ export default class RoomSettingsHandler extends SettingsHandler {
// Special case URL previews // Special case URL previews
if (settingName === "urlPreviewsEnabled") { if (settingName === "urlPreviewsEnabled") {
const content = this._getSettings(roomId, "org.matrix.room.preview_urls"); const content = this._getSettings(roomId, "org.matrix.room.preview_urls");
// Check to make sure that we actually got a boolean
if (typeof(content['disable']) !== "boolean") return null;
return !content['disable']; return !content['disable'];
} }