Commit 2a19553f authored by Ronan Abhamon's avatar Ronan Abhamon

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

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