Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

plaintext encoding issue & handle TLV type 1 #27

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions lib/otr.js
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,12 @@
type = HLP.unpackSHORT(tlvs.substr(0, 2))
len = HLP.unpackSHORT(tlvs.substr(2, 2))

//Disconnected
if(type === 1){
this.msgstate = CONST.MSGSTATE_FINISHED
this.uicb(null, 'Your buddy closed the private connection! You should do the same.')
}

// TODO: handle pathological cases better
if (!len || (len + 4) > tlvs.length) break

Expand Down Expand Up @@ -447,8 +453,10 @@
},

sendMsg: function (msg) {
msg = CryptoJS.enc.Utf8.parse(msg)
msg = msg.toString(CryptoJS.enc.Latin1)
if(this.msgstate == CONST.MSGSTATE_ENCRYPTED){
msg = CryptoJS.enc.Utf8.parse(msg)
msg = msg.toString(CryptoJS.enc.Latin1)
}
this._sendMsg(msg)
},

Expand Down Expand Up @@ -582,4 +590,4 @@
return HLP.packINT(parseInt(BigInt.bigInt2str(num, 10), 10))
}

}).call(this)
}).call(this)