From be56b5080122db174249bd31da3bc5292d33b8df Mon Sep 17 00:00:00 2001 From: Michael Bayne Date: Tue, 16 Apr 2013 08:22:21 -0700 Subject: [PATCH] Strip \r as well as \n when "one-lining" auth blob. Fixes #28. --- .../java/com/threerings/getdown/util/ConnectionUtil.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/threerings/getdown/util/ConnectionUtil.java b/src/main/java/com/threerings/getdown/util/ConnectionUtil.java index ee7857b..04bc1d7 100644 --- a/src/main/java/com/threerings/getdown/util/ConnectionUtil.java +++ b/src/main/java/com/threerings/getdown/util/ConnectionUtil.java @@ -28,8 +28,10 @@ public class ConnectionUtil if (userInfo != null) { // Remove any percent-encoding in the username/password userInfo = URLDecoder.decode(userInfo, "UTF-8"); - conn.setRequestProperty("Authorization", "Basic " + - Base64.encodeBase64String(userInfo.getBytes("UTF-8")).replaceAll("\\n","")); + // Now base64 encode the auth info and make it a single line + String encoded = Base64.encodeBase64String(userInfo.getBytes("UTF-8")). + replaceAll("\\n","").replaceAll("\\r", ""); + conn.setRequestProperty("Authorization", "Basic " + encoded); } return conn;