metajack / strophejs

The Strophe.js repository has moved to https://github.com/strophe/strophejs
http://strophe.im/strophejs
MIT License
810 stars 160 forks source link

Digest MD5 fails due to error in Base64.js #113

Open BrettHolton opened 10 years ago

BrettHolton commented 10 years ago

When using SASL Digest-MD5 mechanism, the user will recieve a bad-protocol error because the second challenge response will be:

<response xmlns='urn:ietf:params:xml:ns:xmpp-sasl'>AA==</response>

instead of:

<response xmlns='urn:ietf:params:xml:ns:xmpp-sasl'></response>

I believe I have traced this down to the Base64 encode implementation. In Base64.js the encode function is implemented as a do while(), this means that the empty challenge response of "" gets encoded to AA== which then gets sent to the server and results in failure. This implementation of Base64 encoding does not cause this error. http://www.webtoolkit.info/javascript-base64.html#.Up0Pr8Try4E