Re: [JGIT PATCH] Fixed a bug that caused tabs in ~/.ssh/config to break parsing

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Gilion Goudsmit <ggoudsmit@xxxxxxxxxx> 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 <ggoudsmit@xxxxxxxxxx>
> ---

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
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux