From: Jonas Fonseca Date: Sat, 20 Sep 2008 22:29:58 GMT Subject: Re: [JGIT PATCH] Fixed a bug that caused tabs in ~/.ssh/config to break parsing Message-ID: <20080920222958.GA18981@diku.dk> In-Reply-To: <12219428213749-git-send-email-ggoudsmit@shebang.nl> Gilion Goudsmit wrote Sat, Sep 20, 2008: > Having only tab-characters separating a key and value in the > users ~/.ssh/config would cause the config-parser to fail with > a "String index out of range: -1" exception. Also simplified > the line parsing code my using a two argument split. > > Signed-off-by: Gilion Goudsmit > --- With the following on top, the code will also pass the updated test for: Host = somewhere diff --git a/org.spearce.jgit/src/org/spearce/jgit/transport/OpenSshConfig.java b/org.spearce.jgit/src/org/spearce/jgit/transport/OpenSshConfig.java index 5bfcf5f..a9c6c12 100644 --- a/org.spearce.jgit/src/org/spearce/jgit/transport/OpenSshConfig.java +++ b/org.spearce.jgit/src/org/spearce/jgit/transport/OpenSshConfig.java @@ -167,7 +167,7 @@ public Host lookup(final String hostName) { if (line.length() == 0 || line.startsWith("#")) continue; - final String[] parts = line.split("[ \t=]", 2); + final String[] parts = line.split("[ \t]*[= \t]", 2); final String keyword = parts[0].trim(); final String argValue = parts[1].trim(); -- Jonas Fonseca