mirror of
https://git.jami.net/savoirfairelinux/jami-client-qt.git
synced 2025-09-10 03:53:23 +02:00
messagewebview: add support for pasting and drafting js special characters
Note: it will also prevent potential js template literal Gitlab: #250 Gitlab: #246 Change-Id: Ic925a18ae768d168b8e340f9e05ef6ddd0260c84
This commit is contained in:
parent
08236cf5e7
commit
44ebb170ff
2 changed files with 14 additions and 4 deletions
|
@ -43,6 +43,10 @@ Rectangle {
|
|||
signal messagesCleared
|
||||
signal messagesLoaded
|
||||
|
||||
function setSendMessageContent(content) {
|
||||
jsBridgeObject.setSendMessageContentRequest(content)
|
||||
}
|
||||
|
||||
function focusMessageWebView() {
|
||||
messageWebView.forceActiveFocus()
|
||||
}
|
||||
|
@ -140,6 +144,10 @@ Rectangle {
|
|||
// ID, under which this object will be known at chatview.js side.
|
||||
WebChannel.id: "jsbridge"
|
||||
|
||||
// signals to trigger functions in chatview.js
|
||||
// mainly used to avoid input arg string escape
|
||||
signal setSendMessageContentRequest(string content)
|
||||
|
||||
// Functions that are exposed, return code can be derived from js side
|
||||
// by setting callback function.
|
||||
function deleteInteraction(arg) {
|
||||
|
@ -240,6 +248,8 @@ Rectangle {
|
|||
|
||||
settings.javascriptEnabled: true
|
||||
settings.javascriptCanOpenWindows: true
|
||||
settings.javascriptCanAccessClipboard: true
|
||||
settings.javascriptCanPaste: true
|
||||
settings.fullScreenSupportEnabled: true
|
||||
settings.allowRunningInsecureContent: true
|
||||
settings.localContentCanAccessRemoteUrls: true
|
||||
|
|
|
@ -421,10 +421,11 @@ MessagesAdapter::pasteKeyDetected()
|
|||
}
|
||||
}
|
||||
} else {
|
||||
// Treat as text content, make chatview.js handle in order to
|
||||
// avoid string escape problems
|
||||
QMetaObject::invokeMethod(qmlObj_,
|
||||
"webViewRunJavaScript",
|
||||
Q_ARG(QVariant,
|
||||
QStringLiteral("replaceText(`%1`)").arg(mimeData->text())));
|
||||
Q_ARG(QVariant, QStringLiteral("replaceText()")));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -640,8 +641,7 @@ MessagesAdapter::removeInteraction(uint64_t interactionId)
|
|||
void
|
||||
MessagesAdapter::setSendMessageContent(const QString& content)
|
||||
{
|
||||
QString s = QString::fromLatin1("setSendMessageContent(`%1`);").arg(content);
|
||||
QMetaObject::invokeMethod(qmlObj_, "webViewRunJavaScript", Q_ARG(QVariant, s));
|
||||
QMetaObject::invokeMethod(qmlObj_, "setSendMessageContent", Q_ARG(QVariant, content));
|
||||
}
|
||||
|
||||
void
|
||||
|
|
Loading…
Add table
Reference in a new issue