fix(chat) prevent homograph attacks

Decode URLs using punycode when rendering, so when http://ebаy.com is sent
we render http://xn--eby-7cd.com/ instead.

Ref: https://github.com/tasti/react-linkify/issues/84
This commit is contained in:
Saúl Ibarra Corretgé
2020-09-25 12:02:46 +02:00
committed by Saúl Ibarra Corretgé
parent 0f9e01a7cf
commit 11ae187ece
4 changed files with 10 additions and 2 deletions

View File

@@ -1,5 +1,6 @@
// @flow
import punycode from 'punycode';
import React, { Component } from 'react';
import ReactLinkify from 'react-linkify';
import { Text } from 'react-native';
@@ -68,7 +69,7 @@ export default class Linkify extends Component<Props> {
key = { key }
style = { this.props.linkStyle }
url = { decoratedHref }>
{decoratedText}
{ punycode.toASCII(decoratedText) }
</Link>
);
}