mirror of
https://gitlab.linphone.org/BC/public/linphone-desktop.git
synced 2026-01-23 06:38:07 +00:00
feat(Utils/uri-tools): replace and escape html caracters like <
This commit is contained in:
parent
9991bf23b8
commit
3ce0f2f22c
4 changed files with 23 additions and 9 deletions
|
|
@ -162,10 +162,10 @@ ColumnLayout {
|
|||
|
||||
// TMP
|
||||
model: ListModel {
|
||||
ListElement { $dateSection: 1465389121000; $outgoing: true; $timestamp: 1465389121000; $type: 'message'; $content: "<a href='http://google.fr'>click here</a>" }
|
||||
ListElement { $dateSection: 1465389121000; $outgoing: true; $timestamp: 1465389121000; $type: 'message'; $content: "<img src='http://html.com/wp-content/uploads/html-com-1.png' width='50%' height='50%' />www.google.fr" }
|
||||
ListElement { $dateSection: 1465389121000; $outgoing: true; $timestamp: 1465389121000; $type: 'message'; $content: "<a href='mailto:qq1@qqpart.com'>Contact mail</a>" }
|
||||
ListElement { $dateSection: 1465389121000; $timestamp: 1465389133000; $type: 'event'; $content: 'incoming_call' }
|
||||
ListElement { $dateSection: 1465389121000; $timestamp: 1465389439000; $type: 'message'; $content: 'Perfect! bg g vg gv v g v hgv gv gv jhb jh b jb jh hg vg cfcy f v u uyg f tf tf ft f tf t t fy ft f tu ty f rd rd d d uu gu y gg y f r dr ' }
|
||||
ListElement { $dateSection: 1465389121000; $timestamp: 1465389439000; $type: 'message'; $content: '<blink>Perfect!</blink> bg g vg gv v g v hgv gv gv jhb jh b jb jh hg vg cfcy f v u uyg f tf tf ft f tf t t fy ft f tu ty f rd rd d d uu gu y gg y f r dr ' }
|
||||
ListElement { $dateSection: 1465389121000; $timestamp: 1465389500000; $type: 'event'; $content: 'end_call' }
|
||||
ListElement { $dateSection: 1465994221000; $outgoing: true; $timestamp: 1465924321000; $type: 'message'; $content: 'You\'ve heard the expression, "Just believe it and it will come." Well, technically, that is true, however, \'believing\' is not just thinking that you can have it...' }
|
||||
ListElement { $dateSection: 1465994221000; $timestamp: 1465924391000; $type: 'event'; $content: 'lost_incoming_call' }
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
import QtQuick 2.7
|
||||
|
||||
import Linphone.Styles 1.0
|
||||
import Utils 1.0
|
||||
|
||||
// ===================================================================
|
||||
|
||||
|
|
@ -36,12 +37,16 @@ Item {
|
|||
right: container.right
|
||||
}
|
||||
padding: ChatStyle.entry.message.padding
|
||||
text: $content
|
||||
text: Utils.encodeUrisToQmlFormat($content)
|
||||
wrapMode: Text.Wrap
|
||||
|
||||
// Little fix. Text may disappear with scrolling.
|
||||
renderType: Text.NativeRendering
|
||||
|
||||
// See http://doc.qt.io/qt-5/qml-qtquick-text.html#textFormat-prop
|
||||
// and http://doc.qt.io/qt-5/richtext-html-subset.html
|
||||
textFormat: Text.StyledText
|
||||
|
||||
onLinkActivated: Qt.openUrlExternally(link)
|
||||
|
||||
MouseArea {
|
||||
|
|
|
|||
|
|
@ -2,6 +2,8 @@
|
|||
// Library to deal with URI.
|
||||
// ===================================================================
|
||||
|
||||
.pragma library
|
||||
|
||||
// Level 0. ----------------------------------------------------------
|
||||
|
||||
var URI_PCT_ENCODED = '%[A-Fa-f\\d]{2}'
|
||||
|
|
@ -84,12 +86,6 @@ var URI_REGEX = new RegExp(URI, 'g')
|
|||
|
||||
// ===================================================================
|
||||
|
||||
function test () {
|
||||
console.log('TOTO', URI_REGEX)
|
||||
console.log('fe ef ef ef feff eff e fefefefe http://99w-w*w.test.com efeffe effe f ffe eef'.match(URI_REGEX))
|
||||
}
|
||||
test()
|
||||
|
||||
/* TODO: Supports:
|
||||
|
||||
URI-reference = URI / relative-ref
|
||||
|
|
|
|||
|
|
@ -2,6 +2,8 @@
|
|||
// Contains many common helpers.
|
||||
// ===================================================================
|
||||
|
||||
.import 'uri-tools.js' as UriTools
|
||||
|
||||
// Load by default a window in the ui/views folder.
|
||||
// If options.isString is equals to true, a marshalling component can
|
||||
// be used.
|
||||
|
|
@ -240,3 +242,14 @@ function genRandomNumberBetweenIntervals (intervals) {
|
|||
|
||||
return n
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
|
||||
function encodeUrisToQmlFormat (text) {
|
||||
return text
|
||||
.replace(/</g, '<')
|
||||
.replace(/>/g, '>')
|
||||
.replace(UriTools.URI_REGEX, function (match) {
|
||||
return '<a href="' + match + '">' + match + '</a>'
|
||||
})
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue