Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDoug Kelly2015-12-09 22:36:37 +0000
committerDoug Kelly2015-12-09 22:48:20 +0000
commit618b0c1ceb65fa26475e9706dd9a64a28ff788db (patch)
treec1a46a7aa9505f045120373baefcc9d052f4bc6b
parent6dfad98d7237236661414f96eb302ed1013a2ecc (diff)
downloadjgit-618b0c1ceb65fa26475e9706dd9a64a28ff788db.tar.gz
jgit-618b0c1ceb65fa26475e9706dd9a64a28ff788db.tar.xz
jgit-618b0c1ceb65fa26475e9706dd9a64a28ff788db.zip
Accept UTF8 BOM with BlobBasedConfig
In I1f5dc07182dbf6bba2a9f4807fdd25b475da4ead, FileBasedConfig got support for reading a configuration with UTF8 BOM. Apply the same support to BlobBasedConfig, to make SubmoduleWalk able to parse .gitmodules configurations with BOM. Change-Id: I25b5474779952fe2c076180b96fc2869eef190a8 Signed-off-by: Doug Kelly <dougk.ff7@gmail.com>
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/lib/BlobBasedConfig.java10
1 files changed, 9 insertions, 1 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/lib/BlobBasedConfig.java b/org.eclipse.jgit/src/org/eclipse/jgit/lib/BlobBasedConfig.java
index cbb2f5b856..7d52991df0 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/lib/BlobBasedConfig.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/lib/BlobBasedConfig.java
@@ -79,7 +79,15 @@ public class BlobBasedConfig extends Config {
public BlobBasedConfig(Config base, final byte[] blob)
throws ConfigInvalidException {
super(base);
- fromText(RawParseUtils.decode(blob));
+ final String decoded;
+ if (blob.length >= 3 && blob[0] == (byte) 0xEF
+ && blob[1] == (byte) 0xBB && blob[2] == (byte) 0xBF) {
+ decoded = RawParseUtils.decode(RawParseUtils.UTF8_CHARSET,
+ blob, 3, blob.length);
+ } else {
+ decoded = RawParseUtils.decode(blob);
+ }
+ fromText(decoded);
}
/**

Back to the top