From a13d58f6c254aa8cd057edefdd54b229108b633b Mon Sep 17 00:00:00 2001 From: Richard Lewis Date: Thu, 24 May 2018 14:58:59 +0100 Subject: [PATCH 1/6] More thorough check of IM URL validity. --- src/components/views/elements/AppTile.js | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/src/components/views/elements/AppTile.js b/src/components/views/elements/AppTile.js index 0895ede636..e4d003b59b 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; From 9753ee8d825001e76e726d2173068ee5d144ac31 Mon Sep 17 00:00:00 2001 From: Richard Lewis Date: Thu, 24 May 2018 16:14:18 +0100 Subject: [PATCH 2/6] Better check of jitsi widget message origin. --- src/components/views/elements/AppTile.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/components/views/elements/AppTile.js b/src/components/views/elements/AppTile.js index e4d003b59b..018b6cb342 100644 --- a/src/components/views/elements/AppTile.js +++ b/src/components/views/elements/AppTile.js @@ -278,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; } From 24aeda2e05eed18d836df8d809abb75ff994edcc Mon Sep 17 00:00:00 2001 From: Luke Barnard Date: Thu, 24 May 2018 16:52:04 +0100 Subject: [PATCH 3/6] Fix bug where usage data link not visible when no cookie policy url --- src/components/views/globals/CookieBar.js | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/components/views/globals/CookieBar.js b/src/components/views/globals/CookieBar.js index ad00884dd2..82ac598532 100644 --- a/src/components/views/globals/CookieBar.js +++ b/src/components/views/globals/CookieBar.js @@ -76,7 +76,20 @@ export default class CookieBar extends React.Component { , }, - ) : _t("Help improve Riot by sending usage data? This will use a cookie.") } + ) : _t( + "Help improve Riot by sending usage data? " + + "This will use a cookie.", + {}, + { + 'UsageDataLink': (sub) => + { sub } + , + }, + ) } { _t("Yes please") } From 9d2f223773a3c73a7eec78d200266672033b93e8 Mon Sep 17 00:00:00 2001 From: David Baker Date: Thu, 24 May 2018 16:54:48 +0100 Subject: [PATCH 4/6] Message for leaving server notices room --- src/components/structures/MatrixChat.js | 16 +++++++++++++--- src/i18n/strings/en_EN.json | 2 ++ 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/src/components/structures/MatrixChat.js b/src/components/structures/MatrixChat.js index 96e721f7ca..a3b243f8bc 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 Home Server, " + + "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/i18n/strings/en_EN.json b/src/i18n/strings/en_EN.json index 41f1780425..f334a94d4e 100644 --- a/src/i18n/strings/en_EN.json +++ b/src/i18n/strings/en_EN.json @@ -949,6 +949,8 @@ "This room is not public. You will not be able to rejoin without an invite.": "This room is not public. You will not be able to rejoin without an invite.", "Are you sure you want to leave the room '%(roomName)s'?": "Are you sure you want to leave the room '%(roomName)s'?", "Failed to leave room": "Failed to leave room", + "Can't leave Server Notices room": "Can't leave Server Notices room", + "This room is used for important messages from the Home Server, so you cannot leave it.": "This room is used for important messages from the Home Server, so you cannot leave it.", "Signed Out": "Signed Out", "For security, this session has been signed out. Please sign in again.": "For security, this session has been signed out. Please sign in again.", "Terms and Conditions": "Terms and Conditions", From fd8d50173207696fda5e2f01726ec48f048ed91a Mon Sep 17 00:00:00 2001 From: Luke Barnard Date: Thu, 24 May 2018 16:58:14 +0100 Subject: [PATCH 5/6] Update cookie bar wording --- src/components/views/globals/CookieBar.js | 10 +++++----- src/i18n/strings/en_EN.json | 6 +++--- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/components/views/globals/CookieBar.js b/src/components/views/globals/CookieBar.js index 82ac598532..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 { Warning
{ this.props.policyUrl ? _t( - "Help improve Riot by sending usage data? " + - "This will use a cookie. " + - "(See our cookie and privacy policies).", + "Please help improve Riot.im by sending anonymous usage data. " + + "This will use a cookie " + + "(please see our Cookie Policy).", {}, { 'UsageDataLink': (sub) => usage data? " + + "Please help improve Riot.im by sending anonymous usage data. " + "This will use a cookie.", {}, { @@ -92,7 +92,7 @@ export default class CookieBar extends React.Component { ) }
- { _t("Yes please") } + { _t("Yes, I want to help!") } diff --git a/src/i18n/strings/en_EN.json b/src/i18n/strings/en_EN.json index 41f1780425..e20b277ef2 100644 --- a/src/i18n/strings/en_EN.json +++ b/src/i18n/strings/en_EN.json @@ -636,9 +636,9 @@ "Something went wrong when trying to get your communities.": "Something went wrong when trying to get your communities.", "Display your community flair in rooms configured to show it.": "Display your community flair in rooms configured to show it.", "You're not currently a member of any communities.": "You're not currently a member of any communities.", - "Help improve Riot by sending usage data? This will use a cookie. (See our cookie and privacy policies).": "Help improve Riot by sending usage data? This will use a cookie. (See our cookie and privacy policies).", - "Help improve Riot by sending usage data? This will use a cookie.": "Help improve Riot by sending usage data? This will use a cookie.", - "Yes please": "Yes please", + "Please help improve Riot.im by sending anonymous usage data. This will use a cookie (please see our Cookie Policy).": "Please help improve Riot.im by sending anonymous usage data. This will use a cookie (please see our Cookie Policy).", + "Please help improve Riot.im by sending anonymous usage data. This will use a cookie.": "Please help improve Riot.im by sending anonymous usage data. This will use a cookie.", + "Yes, I want to help!": "Yes, I want to help!", "You are not receiving desktop notifications": "You are not receiving desktop notifications", "Enable them now": "Enable them now", "What's New": "What's New", From 168b956b3c8c9895c3f8b1e09bf29350b57eba7b Mon Sep 17 00:00:00 2001 From: David Baker Date: Thu, 24 May 2018 17:01:00 +0100 Subject: [PATCH 6/6] homeserver --- src/components/structures/MatrixChat.js | 2 +- src/i18n/strings/en_EN.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/components/structures/MatrixChat.js b/src/components/structures/MatrixChat.js index a3b243f8bc..46c1113a1d 100644 --- a/src/components/structures/MatrixChat.js +++ b/src/components/structures/MatrixChat.js @@ -1001,7 +1001,7 @@ export default React.createClass({ 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 Home Server, " + + "This room is used for important messages from the Homeserver, " + "so you cannot leave it.", ); } else if (err && err.message) { diff --git a/src/i18n/strings/en_EN.json b/src/i18n/strings/en_EN.json index f334a94d4e..07f9f6b8ec 100644 --- a/src/i18n/strings/en_EN.json +++ b/src/i18n/strings/en_EN.json @@ -950,7 +950,7 @@ "Are you sure you want to leave the room '%(roomName)s'?": "Are you sure you want to leave the room '%(roomName)s'?", "Failed to leave room": "Failed to leave room", "Can't leave Server Notices room": "Can't leave Server Notices room", - "This room is used for important messages from the Home Server, so you cannot leave it.": "This room is used for important messages from the Home Server, so you cannot leave it.", + "This room is used for important messages from the Homeserver, so you cannot leave it.": "This room is used for important messages from the Homeserver, so you cannot leave it.", "Signed Out": "Signed Out", "For security, this session has been signed out. Please sign in again.": "For security, this session has been signed out. Please sign in again.", "Terms and Conditions": "Terms and Conditions",