diff options
author | rstular <rok@stular.eu> | 2020-05-14 11:57:37 +0200 |
---|---|---|
committer | rstular <rok@stular.eu> | 2020-05-14 11:57:37 +0200 |
commit | ad55ff1f8024ac88b7948a6d88598dc331054ac5 (patch) | |
tree | 90d34b9b1f2fccc4c7d5198d3824fad4157f3e9a | |
parent | Bug fix (Javascript is wierd) (diff) | |
download | beziapp-ad55ff1f8024ac88b7948a6d88598dc331054ac5.tar beziapp-ad55ff1f8024ac88b7948a6d88598dc331054ac5.tar.gz beziapp-ad55ff1f8024ac88b7948a6d88598dc331054ac5.tar.bz2 beziapp-ad55ff1f8024ac88b7948a6d88598dc331054ac5.tar.lz beziapp-ad55ff1f8024ac88b7948a6d88598dc331054ac5.tar.xz beziapp-ad55ff1f8024ac88b7948a6d88598dc331054ac5.tar.zst beziapp-ad55ff1f8024ac88b7948a6d88598dc331054ac5.zip |
-rw-r--r-- | js/messaging.js | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/js/messaging.js b/js/messaging.js index 60072f0..a5e5f6c 100644 --- a/js/messaging.js +++ b/js/messaging.js @@ -1,5 +1,8 @@ const API_ENDPOINT = "https://gimb.tk/test.php"; const DIRECTORY_URL = "/directory.json"; + +const ENCRYPTED_MESSAGE_REGEX = /<!-- beziapp-e2eemsg-(\d{4}) -->(\S+?)<!-- end-msg -->/g; + // "Global" object for name directory var directory = null; @@ -249,8 +252,9 @@ async function deleteMsg(id) { } function displayMessage(id, data) { - if(data["telo"].substring(0, 21) == "<!-- beziapp-e2eemsg-") { - var datatodecrypt = data["telo"].substring(29 + Number(data["telo"].substring(21, 25)), data["telo"].length - 6) // length-6 da zbrišemo zadnji </div> + let regex_results = ENCRYPTED_MESSAGE_REGEX.exec(data["telo"]); + if (regex_results != null) { + var datatodecrypt = regex_results[1]; // length-6 da zbrišemo zadnji </div> var randomencdivid = Math.floor(Math.random() * 9999).toString().padStart(4, "0"); var msgcontent = ` @@ -274,7 +278,7 @@ function displayMessage(id, data) { $('#beziapp-msg-e2ee-form-${randomencdivid}').hide(); " > - ${S("decrypt")}! + ${S("decrypt")} </button> </div> <div id="beziapp-msg-e2ee-content-${randomencdivid}" hidden> @@ -464,9 +468,7 @@ function setupEventListeners() { > </div> <div id="beziapp-msg-e2ee-content-${randomencdivid}" hidden> - <!-- beziapp-e2eemsg-${msgcontent.length.toString().padStart(4, "0")} --> - ${msgcontent} - ${sjcl.encrypt($("#msg-e2ee-pass-input").val(), $("#msg-body").val())} + <!-- beziapp-e2eemsg-${msgcontent.length.toString().padStart(4, "0")} -->${sjcl.encrypt($("#msg-e2ee-pass-input").val(), msgcontent)}<!-- end-msg --> </div> ` } |