changeset 589:c18095eedde0

Username in changeset uses UTF-8, not system encoding
author Artem Tikhomirov <tikhomirov.artem@gmail.com>
date Mon, 29 Apr 2013 17:02:30 +0200
parents 41218d84842a
children 8cbc2a883d95
files src/org/tmatesoft/hg/repo/HgChangelog.java
diffstat 1 files changed, 13 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/src/org/tmatesoft/hg/repo/HgChangelog.java	Mon Apr 29 16:37:57 2013 +0200
+++ b/src/org/tmatesoft/hg/repo/HgChangelog.java	Mon Apr 29 17:02:30 2013 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010-2012 TMate Software Ltd
+ * Copyright (c) 2010-2013 TMate Software Ltd
  *  
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -247,10 +247,19 @@
 			if (breakIndex2 == -1) {
 				throw new HgInvalidDataFormatException("Bad Changeset data");
 			}
-			String _user = new String(data, breakIndex1 + 1, breakIndex2 - breakIndex1 - 1);
-			if (usersPool != null) {
-				_user = usersPool.unify(_user);
+			String _user;
+			try {
+				// TODO use encoding helper? Although where encoding is fixed (like here), seems to be just too much
+				_user = new String(data, breakIndex1 + 1, breakIndex2 - breakIndex1 - 1, "UTF-8");
+				if (usersPool != null) {
+					_user = usersPool.unify(_user);
+				}
+			} catch (UnsupportedEncodingException ex) {
+				_user = "";
+				// Could hardly happen
+				throw new HgInvalidDataFormatException("Bad Changeset data", ex);
 			}
+
 			int breakIndex3 = indexOf(data, lineBreak, breakIndex2 + 1, bufferEndIndex);
 			if (breakIndex3 == -1) {
 				throw new HgInvalidDataFormatException("Bad Changeset data");