diff options
author | James Moger <james.moger@gitblit.com> | 2014-09-04 12:28:33 -0600 |
---|---|---|
committer | James Moger <james.moger@gitblit.com> | 2014-09-04 12:28:33 -0600 |
commit | 624a7215a635630508d12b80508e0df708632066 (patch) | |
tree | 1873d3f20572944aa001da092757ca0160577a6e | |
parent | 3a916413835a92706394ec55f177eeb23f709d89 (diff) | |
parent | e685ba747e18ed55690c3c697b3e87cdd661fc7f (diff) | |
download | gitblit-624a7215a635630508d12b80508e0df708632066.tar.gz gitblit-624a7215a635630508d12b80508e0df708632066.zip |
Merged #151 "Treat UTF-9 and UTF-18 (fake) encodings as UTF-8"
-rw-r--r-- | src/main/java/com/gitblit/manager/RepositoryManager.java | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/main/java/com/gitblit/manager/RepositoryManager.java b/src/main/java/com/gitblit/manager/RepositoryManager.java index 0160363e..a8b23237 100644 --- a/src/main/java/com/gitblit/manager/RepositoryManager.java +++ b/src/main/java/com/gitblit/manager/RepositoryManager.java @@ -21,6 +21,7 @@ import java.io.IOException; import java.lang.reflect.Field; import java.net.URI; import java.net.URISyntaxException; +import java.nio.charset.Charset; import java.text.MessageFormat; import java.text.SimpleDateFormat; import java.util.ArrayList; @@ -52,6 +53,7 @@ import org.eclipse.jgit.storage.file.FileBasedConfig; import org.eclipse.jgit.storage.file.WindowCacheConfig; import org.eclipse.jgit.util.FS; import org.eclipse.jgit.util.FileUtils; +import org.eclipse.jgit.util.RawParseUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -1895,6 +1897,18 @@ public class RepositoryManager implements IRepositoryManager { } catch (IllegalArgumentException e) { logger.error("Failed to configure JGit parameters!", e); } + + try { + // issue-486/ticket-151: UTF-9 & UTF-18 + Field field = RawParseUtils.class.getDeclaredField("encodingAliases"); + field.setAccessible(true); + Map<String, Charset> encodingAliases = (Map<String, Charset>) field.get(null); + encodingAliases.put("utf-9", RawParseUtils.UTF8_CHARSET); + encodingAliases.put("utf-18", RawParseUtils.UTF8_CHARSET); + logger.info("Alias UTF-9 & UTF-18 encodings as UTF-8 in JGit"); + } catch (Throwable t) { + logger.error("Failed to inject UTF-9 & UTF-18 encoding aliases into JGit", t); + } } protected void configureCommitCache() { |