diff --git a/src/components/structures/MatrixChat.js b/src/components/structures/MatrixChat.js index 96e721f7ca..46c1113a1d 100644 --- a/src/components/structures/MatrixChat.js +++ b/src/components/structures/MatrixChat.js @@ -996,10 +996,20 @@ export default React.createClass({ }, (err) => { modal.close(); console.error("Failed to leave room " + roomId + " " + err); + let title = _t("Failed to leave room"); + let message = _t("Server may be unavailable, overloaded, or you hit a bug."); + if (err.errcode == 'M_CANNOT_LEAVE_SERVER_NOTICE_ROOM') { + title = _t("Can't leave Server Notices room"); + message = _t( + "This room is used for important messages from the Homeserver, " + + "so you cannot leave it.", + ); + } else if (err && err.message) { + message = err.message; + } Modal.createTrackedDialog('Failed to leave room', '', ErrorDialog, { - title: _t("Failed to leave room"), - description: (err && err.message ? err.message : - _t("Server may be unavailable, overloaded, or you hit a bug.")), + title: title, + description: message, }); }); } diff --git a/src/components/views/elements/AppTile.js b/src/components/views/elements/AppTile.js index 0895ede636..018b6cb342 100644 --- a/src/components/views/elements/AppTile.js +++ b/src/components/views/elements/AppTile.js @@ -122,23 +122,32 @@ export default class AppTile extends React.Component { /** * Returns true if specified url is a scalar URL, typically https://scalar.vector.im/api - * @param {[type]} url URL to check + * @param {[type]} testUrlString URL to check * @return {Boolean} True if specified URL is a scalar URL */ - isScalarUrl(url) { - if (!url) { + isScalarUrl(testUrlString) { + if (!testUrlString) { console.error('Scalar URL check failed. No URL specified'); return false; } + const testUrl = url.parse(testUrlString); + let scalarUrls = SdkConfig.get().integrations_widgets_urls; if (!scalarUrls || scalarUrls.length == 0) { scalarUrls = [SdkConfig.get().integrations_rest_url]; } for (let i = 0; i < scalarUrls.length; i++) { - if (url.startsWith(scalarUrls[i])) { - return true; + const scalarUrl = url.parse(scalarUrls[i]); + if (testUrl && scalarUrl) { + if ( + testUrl.protocol === scalarUrl.protocol && + testUrl.host === scalarUrl.host && + testUrl.pathname.startsWith(scalarUrl.pathname) + ) { + return true; + } } } return false; @@ -269,7 +278,12 @@ export default class AppTile extends React.Component { event.origin = event.originalEvent.origin; } - if (!this.state.widgetUrl.startsWith(event.origin)) { + const widgetUrlObj = url.parse(this.state.widgetUrl); + const eventOrigin = url.parse(event.origin); + if ( + eventOrigin.protocol !== widgetUrlObj.protocol || + eventOrigin.host !== widgetUrlObj.host + ) { return; } diff --git a/src/components/views/globals/CookieBar.js b/src/components/views/globals/CookieBar.js index ad00884dd2..a63a163dd1 100644 --- a/src/components/views/globals/CookieBar.js +++ b/src/components/views/globals/CookieBar.js @@ -54,9 +54,9 @@ export default class CookieBar extends React.Component {