[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]

 



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>
---
 .../org/spearce/jgit/transport/OpenSshConfig.java  |   14 +++-----------
 1 files changed, 3 insertions(+), 11 deletions(-)

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 df38e18..5bfcf5f 100644
--- a/org.spearce.jgit/src/org/spearce/jgit/transport/OpenSshConfig.java
+++ b/org.spearce.jgit/src/org/spearce/jgit/transport/OpenSshConfig.java
@@ -167,17 +167,9 @@ while ((line = br.readLine()) != null) {
 			if (line.length() == 0 || line.startsWith("#"))
 				continue;
 
-			final int sp = line.indexOf(' ');
-			final int eq = line.indexOf('=');
-			final int splitAt;
-			if (sp >= 0 && eq >= 0)
-				splitAt = Math.min(sp, eq);
-			else if (sp < 0)
-				splitAt = eq;
-			else
-				splitAt = sp;
-			final String keyword = line.substring(0, splitAt).trim();
-			final String argValue = line.substring(splitAt + 1).trim();
+			final String[] parts = line.split("[ \t=]", 2);
+			final String keyword = parts[0].trim();
+			final String argValue = parts[1].trim();
 
 			if ("Host".equalsIgnoreCase(keyword)) {
 				current.clear();
-- 
1.5.3.8

--
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