From 1cb53b60f93217bb40ad561332115a676225e7b4 Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Fri, 2 Jul 2021 15:06:27 -0500 Subject: [PATCH] Check URL params defensively, probably fixes #670 --- app/soapbox/features/account_gallery/index.js | 3 ++- app/soapbox/features/account_timeline/index.js | 3 ++- app/soapbox/features/favourited_statuses/index.js | 3 ++- app/soapbox/features/followers/index.js | 3 ++- app/soapbox/features/following/index.js | 3 ++- app/soapbox/features/pinned_statuses/index.js | 3 ++- app/soapbox/pages/profile_page.js | 3 ++- 7 files changed, 14 insertions(+), 7 deletions(-) diff --git a/app/soapbox/features/account_gallery/index.js b/app/soapbox/features/account_gallery/index.js index c127e0d9b..bc2892038 100644 --- a/app/soapbox/features/account_gallery/index.js +++ b/app/soapbox/features/account_gallery/index.js @@ -18,7 +18,8 @@ import { openModal } from 'soapbox/actions/modal'; import { NavLink } from 'react-router-dom'; import { FormattedMessage } from 'react-intl'; -const mapStateToProps = (state, { params: { username }, withReplies = false }) => { +const mapStateToProps = (state, { params, withReplies = false }) => { + const username = params.username || ''; const me = state.get('me'); const accounts = state.getIn(['accounts']); const accountFetchError = (state.getIn(['accounts', -1, 'username'], '').toLowerCase() === username.toLowerCase()); diff --git a/app/soapbox/features/account_timeline/index.js b/app/soapbox/features/account_timeline/index.js index c838d2d63..b2b5fa4d1 100644 --- a/app/soapbox/features/account_timeline/index.js +++ b/app/soapbox/features/account_timeline/index.js @@ -18,7 +18,8 @@ import { getSoapboxConfig } from 'soapbox/actions/soapbox'; const emptyList = ImmutableList(); -const mapStateToProps = (state, { params: { username }, withReplies = false }) => { +const mapStateToProps = (state, { params, withReplies = false }) => { + const username = params.username || ''; const me = state.get('me'); const accounts = state.getIn(['accounts']); const accountFetchError = (state.getIn(['accounts', -1, 'username'], '').toLowerCase() === username.toLowerCase()); diff --git a/app/soapbox/features/favourited_statuses/index.js b/app/soapbox/features/favourited_statuses/index.js index 9e831e03b..58506c357 100644 --- a/app/soapbox/features/favourited_statuses/index.js +++ b/app/soapbox/features/favourited_statuses/index.js @@ -10,7 +10,8 @@ import ImmutablePureComponent from 'react-immutable-pure-component'; import { debounce } from 'lodash'; import MissingIndicator from 'soapbox/components/missing_indicator'; -const mapStateToProps = (state, { params: { username } }) => { +const mapStateToProps = (state, { params }) => { + const username = params.username || ''; const me = state.get('me'); const meUsername = state.getIn(['accounts', me, 'username']); return { diff --git a/app/soapbox/features/followers/index.js b/app/soapbox/features/followers/index.js index ca0d6d2be..079867772 100644 --- a/app/soapbox/features/followers/index.js +++ b/app/soapbox/features/followers/index.js @@ -18,7 +18,8 @@ import ScrollableList from '../../components/scrollable_list'; import MissingIndicator from 'soapbox/components/missing_indicator'; import { getFollowDifference } from 'soapbox/utils/accounts'; -const mapStateToProps = (state, { params: { username }, withReplies = false }) => { +const mapStateToProps = (state, { params, withReplies = false }) => { + const username = params.username || ''; const me = state.get('me'); const accounts = state.getIn(['accounts']); const accountFetchError = (state.getIn(['accounts', -1, 'username'], '').toLowerCase() === username.toLowerCase()); diff --git a/app/soapbox/features/following/index.js b/app/soapbox/features/following/index.js index 6a1d4c461..9148b0949 100644 --- a/app/soapbox/features/following/index.js +++ b/app/soapbox/features/following/index.js @@ -18,7 +18,8 @@ import ScrollableList from '../../components/scrollable_list'; import MissingIndicator from 'soapbox/components/missing_indicator'; import { getFollowDifference } from 'soapbox/utils/accounts'; -const mapStateToProps = (state, { params: { username }, withReplies = false }) => { +const mapStateToProps = (state, { params, withReplies = false }) => { + const username = params.username || ''; const me = state.get('me'); const accounts = state.getIn(['accounts']); const accountFetchError = (state.getIn(['accounts', -1, 'username'], '').toLowerCase() === username.toLowerCase()); diff --git a/app/soapbox/features/pinned_statuses/index.js b/app/soapbox/features/pinned_statuses/index.js index 5eef23e00..27758840c 100644 --- a/app/soapbox/features/pinned_statuses/index.js +++ b/app/soapbox/features/pinned_statuses/index.js @@ -9,7 +9,8 @@ import { injectIntl, FormattedMessage } from 'react-intl'; import ImmutablePureComponent from 'react-immutable-pure-component'; import MissingIndicator from 'soapbox/components/missing_indicator'; -const mapStateToProps = (state, { params: { username } }) => { +const mapStateToProps = (state, { params }) => { + const username = params.username || ''; const me = state.get('me'); const meUsername = state.getIn(['accounts', me, 'username']); return { diff --git a/app/soapbox/pages/profile_page.js b/app/soapbox/pages/profile_page.js index f1617dbdb..648c26b07 100644 --- a/app/soapbox/pages/profile_page.js +++ b/app/soapbox/pages/profile_page.js @@ -16,7 +16,8 @@ import { getFeatures } from 'soapbox/utils/features'; import { makeGetAccount } from '../selectors'; import { Redirect } from 'react-router-dom'; -const mapStateToProps = (state, { params: { username }, withReplies = false }) => { +const mapStateToProps = (state, { params, withReplies = false }) => { + const username = params.username || ''; const accounts = state.getIn(['accounts']); const accountFetchError = (state.getIn(['accounts', -1, 'username'], '').toLowerCase() === username.toLowerCase()); const getAccount = makeGetAccount();