Prevent Sending Blank Messages, fix htmlescape & bug

This commit is contained in:
Sarah Jamie Lewis 2019-02-04 15:26:44 -08:00
parent e7d4cc298d
commit 35778ae4ae
3 changed files with 5 additions and 5 deletions

View File

@ -226,8 +226,11 @@ ColumnLayout {
onClicked: { onClicked: {
if (txtMessage.text != "") { if (txtMessage.text != "") {
txtHidden.text = restoreEmoji(txtMessage.text) txtHidden.text = restoreEmoji(txtMessage.text)
var msg = JSON.stringify({"o":1, "d":txtHidden.getText(0, txtHidden.text.length)}) var txt = txtHidden.getText(0, txtHidden.text.length).trim()
gcd.sendMessage(msg, nextMessageID++) if (txt.length > 0) {
var msg = JSON.stringify({"o":1, "d":txtHidden.getText(0, txtHidden.text.length)})
gcd.sendMessage(msg, nextMessageID++)
}
} }
txtMessage.text = "" txtMessage.text = ""
} }

View File

@ -1,11 +1,8 @@
.pragma library .pragma library
function htmlEscaped(str) { function htmlEscaped(str) {
str = str.replace(/&/g, "&");
str = str.replace(/</g, "&lt;"); str = str.replace(/</g, "&lt;");
str = str.replace(/>/g, "&gt;"); str = str.replace(/>/g, "&gt;");
str = str.replace(/"/g, "&quot;");
str = str.replace(/'/g, "&apos;");
return str return str
} }

Binary file not shown.