Browse Source

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>
tags/v4.2.0.201601211800-r
Doug Kelly 8 years ago
parent
commit
618b0c1ceb
1 changed files with 9 additions and 1 deletions
  1. 9
    1
      org.eclipse.jgit/src/org/eclipse/jgit/lib/BlobBasedConfig.java

+ 9
- 1
org.eclipse.jgit/src/org/eclipse/jgit/lib/BlobBasedConfig.java View File

@@ -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);
}

/**

Loading…
Cancel
Save