Skip to content

Commit

Permalink
feat(Translations): add sanitized formatted html
Browse files Browse the repository at this point in the history
  • Loading branch information
plondon committed May 30, 2018
1 parent bc802e9 commit 0ae3a1b
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 0 deletions.
1 change: 1 addition & 0 deletions packages/blockchain-wallet-v4-frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@
"redux-saga": "0.16.0",
"redux-ui": "0.1.1",
"reselect": "^3.0.1",
"sanitize-html": "1.18.2",
"styled-components": "3.2.4",
"zxcvbn": "4.4.2"
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import React from 'react'
import PropTypes from 'prop-types'
import { FormattedHTMLMessage } from 'react-intl'
import sanitizeHtml from 'sanitize-html'

class SanitizedFormattedHTMLMessage extends React.Component {
clean (dirty) {
return sanitizeHtml(dirty, { allowedTags: ['span', 'a'] })
}

render () {
const { id, defaultMessage } = this.props
const clean = this.clean(defaultMessage)
return clean ? <FormattedHTMLMessage id={id} defaultMessage={clean} /> : null
}
}

SanitizedFormattedHTMLMessage.propTypes = {
id: PropTypes.string.isRequired,
defaultMessage: PropTypes.string.isRequired
}

export default SanitizedFormattedHTMLMessage
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { LinkContainer } from 'react-router-bootstrap'
import { required } from 'services/FormHelper'
import { Button, Link, Separator, Text, TextGroup, HeartbeatLoader } from 'blockchain-info-components'
import { Form, FormError, FormGroup, FormItem, FormLabel, PasswordBox, TextBox } from 'components/Form'
import SanitizedFormattedHTMLMessage from 'components/SanitizedFormattedHTMLMessage'
import Modals from 'modals'
import MobileLogin from 'modals/MobileLogin'

Expand Down

0 comments on commit 0ae3a1b

Please sign in to comment.