Commit 2a19553f authored by Ronan's avatar Ronan
Browse files

fix(ui/scripts/Utils/utils): escape correclty special chars like &, \n, \t...

parent 9d44ccec
......@@ -61,7 +61,7 @@ Item {
padding: ChatStyle.entry.message.padding
readOnly: true
selectByMouse: true
text: Utils.encodeUrisToQmlFormat($chatEntry.content, {
text: Utils.encodeTextToQmlRichFormat($chatEntry.content, {
imagesHeight: ChatStyle.entry.message.images.height,
imagesWidth: ChatStyle.entry.message.images.width
})
......
......@@ -31,7 +31,7 @@ function connectOnce (signal, cb) {
// -------------------------------------------------------------------
function encodeUrisToQmlFormat (text, options) {
function encodeTextToQmlRichFormat (text, options) {
var images = ''
if (options == null) {
......@@ -39,8 +39,12 @@ function encodeUrisToQmlFormat (text, options) {
}
text = text
.replace(/&/g, '&')
.replace(/</g, '\u2063&lt;')
.replace(/>/g, '\u2063&gt;')
.replace(/\r\n|\n/g, '<br/>')
.replace(/\t/g, '&nbsp;&nbsp;&nbsp;&nbsp;')
.replace(/ /g, '&nbsp;')
.replace(UriTools.URI_REGEX, function (match) {
// If it's a simple URL, transforms it in URI.
if (startsWith(match, 'www.')) {
......
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