From 249dd7b8b8ce6694c974667053e444f04632eb81 Mon Sep 17 00:00:00 2001 From: virtuacoplenny <1243084+virtuacoplenny@users.noreply.github.com> Date: Wed, 10 Jul 2019 10:27:11 -0700 Subject: [PATCH] fix(invite): decode the meeting name (#4411) * fix(invite): decode the meeting name * squash: try to make mobile join same encoded meeting name as web * Decodes and generated texts for share and copy meeting info. Decodes in all cases except when it contains a space, as it will generate wrong links when pasted/shared in external applications. --- react/features/base/conference/functions.js | 6 ++- .../components/DeepLinkingMobilePage.web.js | 2 +- .../dial-in-info-page/DialInInfoApp.web.js | 2 +- .../components/info-dialog/web/InfoDialog.js | 37 ++++++++++--------- react/features/invite/functions.js | 23 +++++++++++- .../features/recent-list/functions.native.js | 2 +- react/features/recent-list/functions.web.js | 2 +- .../welcome/components/AbstractWelcomePage.js | 2 +- 8 files changed, 50 insertions(+), 26 deletions(-) diff --git a/react/features/base/conference/functions.js b/react/features/base/conference/functions.js index aa9383c05..493c159a4 100644 --- a/react/features/base/conference/functions.js +++ b/react/features/base/conference/functions.js @@ -160,7 +160,11 @@ export function getConferenceName(stateful: Function | Object): string { const { callDisplayName } = state['features/base/config']; const { pendingSubjectChange, room, subject } = state['features/base/conference']; - return pendingSubjectChange || subject || callDisplayName || (callee && callee.name) || _.startCase(room); + return pendingSubjectChange + || subject + || callDisplayName + || (callee && callee.name) + || _.startCase(decodeURIComponent(room)); } /** diff --git a/react/features/deep-linking/components/DeepLinkingMobilePage.web.js b/react/features/deep-linking/components/DeepLinkingMobilePage.web.js index ac2a2d44c..2bf5fd0d5 100644 --- a/react/features/deep-linking/components/DeepLinkingMobilePage.web.js +++ b/react/features/deep-linking/components/DeepLinkingMobilePage.web.js @@ -217,7 +217,7 @@ class DeepLinkingMobilePage extends Component { */ function _mapStateToProps(state) { return { - _room: state['features/base/conference'].room + _room: decodeURIComponent(state['features/base/conference'].room) }; } diff --git a/react/features/invite/components/dial-in-info-page/DialInInfoApp.web.js b/react/features/invite/components/dial-in-info-page/DialInInfoApp.web.js index 1e27aeace..850fdc583 100644 --- a/react/features/invite/components/dial-in-info-page/DialInInfoApp.web.js +++ b/react/features/invite/components/dial-in-info-page/DialInInfoApp.web.js @@ -21,7 +21,7 @@ document.addEventListener('DOMContentLoaded', () => { ? + room = { decodeURIComponent(room) } /> : } , document.getElementById('react') diff --git a/react/features/invite/components/info-dialog/web/InfoDialog.js b/react/features/invite/components/info-dialog/web/InfoDialog.js index 521782a49..b695e7086 100644 --- a/react/features/invite/components/info-dialog/web/InfoDialog.js +++ b/react/features/invite/components/info-dialog/web/InfoDialog.js @@ -13,7 +13,11 @@ import { getLocalParticipant } from '../../../../base/participants'; -import { _getDefaultPhoneNumber, getDialInfoPageURL } from '../../../functions'; +import { + _decodeRoomURI, + _getDefaultPhoneNumber, + getDialInfoPageURL +} from '../../../functions'; import DialInNumber from './DialInNumber'; import PasswordForm from './PasswordForm'; @@ -237,7 +241,7 @@ class InfoDialog extends Component { className = 'info-dialog-url-text' href = { this.props._inviteURL } onClick = { this._onClickURLText } > - { this._getURLToDisplay() } + { decodeURI(this._getURLToDisplay()) } @@ -288,18 +292,6 @@ class InfoDialog extends Component { ); } - /** - * Generates the URL for the static dial in info page. - * - * @private - * @returns {string} - */ - _getDialInfoPageURL() { - return getDialInfoPageURL( - encodeURIComponent(this.props._conferenceName), - this.props._locationURL); - } - /** * Creates a message describing how to dial in to the conference. * @@ -309,13 +301,14 @@ class InfoDialog extends Component { _getTextToCopy() { const { _localParticipant, liveStreamViewURL, t } = this.props; const shouldDisplayDialIn = this._shouldDisplayDialIn(); + const _inviteURL = _decodeRoomURI(this.props._inviteURL); let invite = _localParticipant && _localParticipant.name ? t('info.inviteURLFirstPartPersonal', { name: _localParticipant.name }) : t('info.inviteURLFirstPartGeneral'); invite += t('info.inviteURLSecondPart', { - url: this.props._inviteURL + url: _inviteURL }); if (liveStreamViewURL) { @@ -332,8 +325,11 @@ class InfoDialog extends Component { conferenceID: this.props.dialIn.conferenceID }); const moreNumbers = t('info.invitePhoneAlternatives', { - url: this._getDialInfoPageURL(), - silentUrl: `${this.props._inviteURL}#config.startSilent=true` + url: getDialInfoPageURL( + this.props._conferenceName, + this.props._locationURL + ), + silentUrl: `${_inviteURL}#config.startSilent=true` }); invite = `${invite}\n${dial}\n${moreNumbers}`; @@ -457,7 +453,12 @@ class InfoDialog extends Component { phoneNumber = { this.state.phoneNumber } /> { this.props.t('info.moreNumbers') } diff --git a/react/features/invite/functions.js b/react/features/invite/functions.js index 98771e285..eaa002bc8 100644 --- a/react/features/invite/functions.js +++ b/react/features/invite/functions.js @@ -401,7 +401,7 @@ export function searchDirectory( // eslint-disable-line max-params */ export function getShareInfoText( state: Object, inviteUrl: string, useHtml: ?boolean): Promise { - let roomUrl = inviteUrl; + let roomUrl = _decodeRoomURI(inviteUrl); const includeDialInfo = state['features/base/config'] !== undefined; if (useHtml) { @@ -505,7 +505,7 @@ export function getDialInfoPageURL( return accumulator; }, ''); - return `${origin}${newPath}/static/dialInInfo.html?room=${conferenceName}`; + return `${origin}${newPath}/static/dialInInfo.html?room=${_decodeRoomURI(conferenceName)}`; } /** @@ -560,3 +560,22 @@ export function _getDefaultPhoneNumber( return null; } + +/** + * Decodes URI only if doesn't contain a space(' '). + * + * @param {string} url - The string to decode. + * @returns {string} - It the string contains space, encoded value is '%20' returns + * same string, otherwise decoded one. + * @private + */ +export function _decodeRoomURI(url: string) { + let roomUrl = url; + + // we want to decode urls when the do not contain space, ' ', which url encoded is %20 + if (roomUrl && !roomUrl.includes('%20')) { + roomUrl = decodeURI(roomUrl); + } + + return roomUrl; +} diff --git a/react/features/recent-list/functions.native.js b/react/features/recent-list/functions.native.js index 49730066f..d5a98a4ce 100644 --- a/react/features/recent-list/functions.native.js +++ b/react/features/recent-list/functions.native.js @@ -31,7 +31,7 @@ function toDisplayableItem(item, defaultServerURL, t) { _toDurationString(item.duration), serverName ], - title: location.room, + title: decodeURIComponent(location.room), url: item.conference }; } diff --git a/react/features/recent-list/functions.web.js b/react/features/recent-list/functions.web.js index 608fc48bc..e7e117aaf 100644 --- a/react/features/recent-list/functions.web.js +++ b/react/features/recent-list/functions.web.js @@ -18,7 +18,7 @@ export function toDisplayableList(recentList) { date: item.date, duration: item.duration, time: [ item.date ], - title: parseURIString(item.conference).room, + title: decodeURIComponent(parseURIString(item.conference).room), url: item.conference }; })); diff --git a/react/features/welcome/components/AbstractWelcomePage.js b/react/features/welcome/components/AbstractWelcomePage.js index 5b741b895..2c47289e9 100644 --- a/react/features/welcome/components/AbstractWelcomePage.js +++ b/react/features/welcome/components/AbstractWelcomePage.js @@ -192,7 +192,7 @@ export class AbstractWelcomePage extends Component { const onAppNavigateSettled = () => this._mounted && this.setState({ joining: false }); - this.props.dispatch(appNavigate(room)) + this.props.dispatch(appNavigate(encodeURI(room))) .then(onAppNavigateSettled, onAppNavigateSettled); } }