From 86bea9e0016b2890db8ba83049dd4e89653a0a5e Mon Sep 17 00:00:00 2001 From: James Moger <james.moger@gitblit.com> Date: Fri, 16 Mar 2012 17:29:39 -0400 Subject: [PATCH] Ensure that the welcome message is interpreted as UTF-8 (issue 74) --- src/com/gitblit/FileUserService.java | 15 ++++++++------- 1 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/com/gitblit/FileUserService.java b/src/com/gitblit/FileUserService.java index 37ca9a7..7842c31 100644 --- a/src/com/gitblit/FileUserService.java +++ b/src/com/gitblit/FileUserService.java @@ -165,11 +165,11 @@ @Override public UserModel getUserModel(String username) { Properties allUsers = read(); - String userInfo = allUsers.getProperty(username); + String userInfo = allUsers.getProperty(username.toLowerCase()); if (userInfo == null) { return null; } - UserModel model = new UserModel(username); + UserModel model = new UserModel(username.toLowerCase()); String[] userValues = userInfo.split(","); model.password = userValues[0]; for (int i = 1; i < userValues.length; i++) { @@ -219,7 +219,7 @@ */ @Override public boolean updateUserModel(String username, UserModel model) { - try { + try { Properties allUsers = read(); UserModel oldUser = getUserModel(username); ArrayList<String> roles = new ArrayList<String>(model.repositories); @@ -241,8 +241,8 @@ } // trim trailing comma sb.setLength(sb.length() - 1); - allUsers.remove(username); - allUsers.put(model.username, sb.toString()); + allUsers.remove(username.toLowerCase()); + allUsers.put(model.username.toLowerCase(), sb.toString()); // null check on "final" teams because JSON-sourced UserModel // can have a null teams object @@ -624,8 +624,9 @@ @Override protected synchronized Properties read() { long lastRead = lastModified(); + boolean reload = forceReload(); Properties allUsers = super.read(); - if (lastRead != lastModified()) { + if (reload || (lastRead != lastModified())) { // reload hash cache cookies.clear(); teams.clear(); @@ -661,7 +662,7 @@ } else { // user definition String password = roles[0]; - cookies.put(StringUtils.getSHA1(username + password), username); + cookies.put(StringUtils.getSHA1(username.toLowerCase() + password), username.toLowerCase()); } } } -- Gitblit v1.9.1