feat: safe decodeURIComponent

pull/4862/head jitsi-meet_4100
Bettenbuk Zoltan 5 years ago committed by Zoltan Bettenbuk
parent 1fd326f980
commit 8bd0da886e
  1. 3
      react/features/base/conference/functions.js
  2. 17
      react/features/base/util/uri.js
  3. 4
      react/features/recent-list/functions.native.js

@ -11,6 +11,7 @@ import {
participantLeft
} from '../participants';
import { toState } from '../redux';
import { safeDecodeURIComponent } from '../util';
import {
AVATAR_ID_COMMAND,
@ -163,7 +164,7 @@ export function getConferenceName(stateful: Function | Object): string {
|| subject
|| callDisplayName
|| (callee && callee.name)
|| _.startCase(decodeURIComponent(room));
|| _.startCase(safeDecodeURIComponent(room));
}
/**

@ -373,6 +373,23 @@ function _standardURIToString(thiz: ?Object) {
return str;
}
/**
* Sometimes we receive strings that we don't know if already percent-encoded, or not, due to the
* various sources we get URLs or room names. This function encapsulates the decoding in a safe way.
*
* @param {string} text - The text to decode.
* @returns {string}
*/
export function safeDecodeURIComponent(text: string) {
try {
return decodeURIComponent(text);
} catch (e) {
// The text wasn't encoded.
}
return text;
}
/**
* Attempts to return a {@code String} representation of a specific
* {@code Object} which is supposed to represent a URL. Obviously, if a

@ -3,7 +3,7 @@ import {
getLocalizedDurationFormatter
} from '../base/i18n';
import { NavigateSectionList } from '../base/react';
import { parseURIString } from '../base/util';
import { parseURIString, safeDecodeURIComponent } from '../base/util';
/**
* Creates a displayable list item of a recent list entry.
@ -31,7 +31,7 @@ function toDisplayableItem(item, defaultServerURL, t) {
_toDurationString(item.duration),
serverName
],
title: decodeURIComponent(location.room),
title: safeDecodeURIComponent(location.room),
url: item.conference
};
}

Loading…
Cancel
Save