From c2c323347ab96b4983786aedd932527692fd0c64 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sa=C3=BAl=20Ibarra=20Corretg=C3=A9?= Date: Thu, 14 Nov 2019 13:33:20 +0100 Subject: [PATCH] rn: skip logging potentially sensitive data --- .../base/storage/PersistenceRegistry.js | 9 ++++--- .../mobile/external-api/middleware.js | 24 +++++++++++++------ 2 files changed, 23 insertions(+), 10 deletions(-) diff --git a/react/features/base/storage/PersistenceRegistry.js b/react/features/base/storage/PersistenceRegistry.js index 66dc12810..7a65ce1dc 100644 --- a/react/features/base/storage/PersistenceRegistry.js +++ b/react/features/base/storage/PersistenceRegistry.js @@ -4,6 +4,8 @@ import md5 from 'js-md5'; import logger from './logger'; +declare var __DEV__; + /** * The name of the {@code localStorage} store where the app persists its values. */ @@ -87,7 +89,9 @@ class PersistenceRegistry { // Initialize the checksum. this._checksum = this._calculateChecksum(filteredPersistedState); - logger.info('redux state rehydrated as', filteredPersistedState); + if (typeof __DEV__ !== 'undefined' && __DEV__) { + logger.info('redux state rehydrated as', filteredPersistedState); + } return filteredPersistedState; } @@ -113,7 +117,6 @@ class PersistenceRegistry { logger.error( 'Error persisting redux subtree', subtreeName, - filteredState[subtreeName], error); } } @@ -153,7 +156,7 @@ class PersistenceRegistry { try { return md5.hex(JSON.stringify(state) || ''); } catch (error) { - logger.error('Error calculating checksum for state', state, error); + logger.error('Error calculating checksum for state', error); return ''; } diff --git a/react/features/mobile/external-api/middleware.js b/react/features/mobile/external-api/middleware.js index 46fd5f6ba..7706338bb 100644 --- a/react/features/mobile/external-api/middleware.js +++ b/react/features/mobile/external-api/middleware.js @@ -15,10 +15,10 @@ import { CONNECTION_DISCONNECTED, CONNECTION_FAILED, JITSI_CONNECTION_CONFERENCE_KEY, - JITSI_CONNECTION_URL_KEY + JITSI_CONNECTION_URL_KEY, + getURLWithoutParams } from '../../base/connection'; import { MiddlewareRegistry } from '../../base/redux'; -import { toURLString } from '../../base/util'; import { ENTER_PICTURE_IN_PICTURE } from '../picture-in-picture'; import { sendEvent } from './functions'; @@ -82,7 +82,7 @@ MiddlewareRegistry.register(store => next => action => { store, CONFERENCE_TERMINATED, /* data */ { - url: toURLString(locationURL) + url: _normalizeUrl(locationURL) }); } @@ -106,7 +106,7 @@ MiddlewareRegistry.register(store => next => action => { CONFERENCE_TERMINATED, /* data */ { error: _toErrorString(error), - url: toURLString(locationURL) + url: _normalizeUrl(locationURL) }); break; } @@ -161,10 +161,20 @@ function _maybeTriggerEarlyConferenceWillJoin(store, action) { store, CONFERENCE_WILL_JOIN, /* data */ { - url: toURLString(locationURL) + url: _normalizeUrl(locationURL) }); } +/** + * Normalizes the given URL for presentation over the external API. + * + * @param {URL} url -The URL to normalize. + * @returns {string} - The normalized URL as a string. + */ +function _normalizeUrl(url: URL) { + return getURLWithoutParams(url).href; +} + /** * Sends an event to the native counterpart of the External API for a specific * conference-related redux action. @@ -186,7 +196,7 @@ function _sendConferenceEvent( // instance. The external API cannot transport such an object so we have to // transport an "equivalent". if (conference) { - data.url = toURLString(conference[JITSI_CONFERENCE_URL_KEY]); + data.url = _normalizeUrl(conference[JITSI_CONFERENCE_URL_KEY]); } if (_swallowEvent(store, action, data)) { @@ -233,7 +243,7 @@ function _sendConferenceFailedOnConnectionError(store, action) { store, CONFERENCE_TERMINATED, /* data */ { - url: toURLString(locationURL), + url: _normalizeUrl(locationURL), error: action.error.name }); }