Commit 9557c238 authored by Harrison Healey's avatar Harrison Healey Committed by Chris
Browse files

PLT-7812/PLT-7813 Fixed link text (#116)

* Update mobile app links

* Updated opengraph link
parent eebaecf8
......@@ -6,6 +6,8 @@ import React from 'react';
import {FormattedMessage} from 'react-intl';
import {Link} from 'react-router';
import {useSafeUrl} from 'utils/url';
import MattermostIcon from 'images/favicon/android-chrome-192x192.png';
import Nexus6Mockup from 'images/nexus-6p-mockup.png';
......@@ -41,7 +43,7 @@ export default function GetAndroidApp() {
</div>
<a
className='btn btn-primary get-android-app__continue'
href={global.window.mm_config.AndroidAppDownloadLink}
href={useSafeUrl(global.window.mm_config.AndroidAppDownloadLink)}
>
<FormattedMessage
id='get_app.continue'
......
......@@ -6,6 +6,8 @@ import React from 'react';
import {FormattedMessage} from 'react-intl';
import {Link} from 'react-router';
import {useSafeUrl} from 'utils/url';
import AppStoreButton from 'images/app-store-button.png';
import IPhone6Mockup from 'images/iphone-6-mockup.png';
......@@ -21,7 +23,7 @@ export default function GetIosApp() {
<hr/>
<a
className='get-ios-app__app-store-link'
href={global.window.mm_config.IosAppDownloadLink}
href={useSafeUrl(global.window.mm_config.IosAppDownloadLink)}
rel='noopener noreferrer'
>
<img src={AppStoreButton}/>
......
......@@ -7,9 +7,10 @@ import PropTypes from 'prop-types';
import {postListScrollChange} from 'actions/global_actions.jsx';
import {updatePost} from 'actions/post_actions.jsx';
import * as Utils from 'utils/utils.jsx';
import * as CommonUtils from 'utils/commons.jsx';
import {PostTypes} from 'utils/constants.jsx';
import {useSafeUrl} from 'utils/url';
import * as Utils from 'utils/utils.jsx';
export default class PostAttachmentOpenGraph extends React.PureComponent {
static propTypes = {
......@@ -50,7 +51,7 @@ export default class PostAttachmentOpenGraph extends React.PureComponent {
constructor(props) {
super(props);
this.largeImageMinWidth = 150;
this.imageDimentions = { // Image dimentions in pixels.
this.imageDimentions = { // Image dimentions in pixels.
height: 80,
width: 80
};
......@@ -297,7 +298,7 @@ export default class PostAttachmentOpenGraph extends React.PureComponent {
>
<a
className='attachment__title-link attachment__title-link--opengraph'
href={data.url || this.props.link}
href={useSafeUrl(data.url || this.props.link)}
target='_blank'
rel='noopener noreferrer'
title={data.title || data.url || this.props.link}
......
......@@ -16,6 +16,7 @@ import TeamMembersModal from './team_members_modal.jsx';
import AddUsersToTeam from 'components/add_users_to_team';
import {Constants, WebrtcActionTypes} from 'utils/constants.jsx';
import {useSafeUrl} from 'utils/url';
import {Dropdown} from 'react-bootstrap';
import {FormattedMessage} from 'react-intl';
......@@ -472,7 +473,7 @@ export default class SidebarHeaderDropdown extends React.Component {
<Link
target='_blank'
rel='noopener noreferrer'
to={global.window.mm_config.AppDownloadLink}
to={useSafeUrl(global.window.mm_config.AppDownloadLink)}
>
<FormattedMessage
id='navbar_dropdown.nativeApps'
......
......@@ -43,3 +43,11 @@ export function isUrlSafe(url) {
!unescaped.startsWith('vbscript:') &&
!unescaped.startsWith('data:');
}
export function useSafeUrl(url, defaultUrl = '') {
if (isUrlSafe(url)) {
return url;
}
return defaultUrl;
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment