1
0
Fork 0
mirror of https://codeberg.org/Mercury-IM/Smack synced 2024-11-21 22:02:06 +01:00

Handle preceding whitespace in DIGEST-MD5

implementation from smack-sasl-provided.

Fixes SMACK-649.
This commit is contained in:
Florian Schmaus 2015-03-31 10:04:53 +02:00
parent 54cbd9a50a
commit 5597b1ffc0

View file

@ -104,6 +104,13 @@ public class SASLDigestMD5Mechanism extends SASLMechanism {
String[] keyValue = part.split("=");
assert (keyValue.length == 2);
String key = keyValue[0];
// RFC 2831 § 7.1 about the formating of the digest-challenge:
// "The full form is "<n>#<m>element" indicating at least <n> and
// at most <m> elements, each separated by one or more commas
// (",") and OPTIONAL linear white space (LWS)."
// Which means the key value may be preceded by whitespace,
// which is what we remove: *Only the preceding whitespace*.
key = key.replaceFirst("^\\s+", "");
String value = keyValue[1];
if ("nonce".equals(key)) {
if (nonce != null) {