diff --git a/js/src/views/Signer/components/SignRequest/signRequest.css b/js/src/views/Signer/components/SignRequest/signRequest.css index a8b3ddd6d..150f8033f 100644 --- a/js/src/views/Signer/components/SignRequest/signRequest.css +++ b/js/src/views/Signer/components/SignRequest/signRequest.css @@ -28,12 +28,12 @@ } .signData { + background: rgba(255,255,255, 0.25); border: 0.25em solid red; - margin-left: 2em; - padding: 0.5em; + font-size: 0.75em; + padding: 0.5rem; overflow: auto; - max-height: 6em; - max-width: calc(100% - 2em); + max-height: 10em; } .signData > p { diff --git a/js/src/views/Signer/components/SignRequest/signRequest.js b/js/src/views/Signer/components/SignRequest/signRequest.js index 2f97f140f..f4f4d27d1 100644 --- a/js/src/views/Signer/components/SignRequest/signRequest.js +++ b/js/src/views/Signer/components/SignRequest/signRequest.js @@ -18,8 +18,10 @@ import { observer } from 'mobx-react'; import React, { Component, PropTypes } from 'react'; import { FormattedMessage } from 'react-intl'; import { connect } from 'react-redux'; +import ReactMarkdown from 'react-markdown'; import ReactTooltip from 'react-tooltip'; +import { hexToAscii } from '~/api/util/format'; import HardwareStore from '~/mobx/hardwareStore'; import Account from '../Account'; @@ -29,16 +31,39 @@ import RequestOrigin from '../RequestOrigin'; import styles from './signRequest.css'; function isAscii (data) { - for (var i = 2; i < data.length; i += 2) { + for (let i = 2; i < data.length; i += 2) { let n = parseInt(data.substr(i, 2), 16); if (n < 32 || n >= 128) { return false; } } + return true; } +function decodeMarkdown (data) { + return decodeURIComponent(escape(hexToAscii(data))); +} + +export function isMarkdown (data) { + try { + const decoded = decodeMarkdown(data); + + for (let i = 0; i < decoded.length; i++) { + const code = decoded.charCodeAt(i); + + if (code < 32 && code !== 10) { + return false; + } + } + + return decoded.indexOf('#') !== -1 || decoded.indexOf('*') !== -1; + } catch (error) { + return false; + } +} + @observer class SignRequest extends Component { static contextTypes = { @@ -113,29 +138,26 @@ class SignRequest extends Component { ); } - renderAsciiDetails (ascii) { - return ( -
{ascii}
-
-
{ this.renderData(data) }
+