From 4c2d5d797a77a14951fb97a96913fb443c869a12 Mon Sep 17 00:00:00 2001 From: Florian Schmaus Date: Wed, 10 Dec 2014 14:16:34 +0100 Subject: [PATCH] Ensure that the hash value is put in lowercase on the wire --- .../java/org/jivesoftware/smackx/caps/EntityCapsManager.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/caps/EntityCapsManager.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/caps/EntityCapsManager.java index 4a753e242..7017a746a 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/caps/EntityCapsManager.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/caps/EntityCapsManager.java @@ -596,9 +596,14 @@ public class EntityCapsManager extends Manager { if (hash == null) { hash = DEFAULT_HASH; } + // SUPPORTED_HASHES uses the format of MessageDigest, which is uppercase, e.g. "SHA-1" instead of "sha-1" MessageDigest md = SUPPORTED_HASHES.get(hash.toUpperCase(Locale.US)); if (md == null) return null; + // Then transform the hash to lowercase, as this value will be put on the wire within the caps element's hash + // attribute. I'm not sure if the standard is case insensitive here, but let's assume that even it is, there could + // be "broken" implementation in the wild, so we *always* transform to lowercase. + hash = hash.toLowerCase(Locale.US); DataForm extendedInfo = DataForm.from(discoverInfo);