From 77907e4570d7f0be78f714e21958bda16bfb4250 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20M=C3=BCnch?= Date: Wed, 20 Aug 2014 00:00:21 +0200 Subject: [PATCH] [BUGFIX] Added support for .ssh/config files indented with tabs or spaces --- src/Ssh/SshConfigFileConfiguration.php | 3 ++- tests/Ssh/Fixtures/config_valid | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/Ssh/SshConfigFileConfiguration.php b/src/Ssh/SshConfigFileConfiguration.php index 05b3cb8..0cd63cb 100644 --- a/src/Ssh/SshConfigFileConfiguration.php +++ b/src/Ssh/SshConfigFileConfiguration.php @@ -60,7 +60,8 @@ protected function parseSshConfigFile($file) $configs = array(); $lineNumber = 1; foreach (explode(PHP_EOL, $contents) as $line) { - if (trim($line) == '' || $line[0] == '#') { + $line = trim($line); + if ($line == '' || $line[0] == '#') { continue; } $pos = strpos($line, '='); diff --git a/tests/Ssh/Fixtures/config_valid b/tests/Ssh/Fixtures/config_valid index 1fc2788..e9635a2 100644 --- a/tests/Ssh/Fixtures/config_valid +++ b/tests/Ssh/Fixtures/config_valid @@ -5,7 +5,7 @@ Port 1234 #This is a comment which won't appear in the parsed array Host test -HostName test.com + HostName test.com Host testuser.com User test @@ -21,4 +21,4 @@ IdentityFile ~/identity Host ta* User bob Port = 12345 -HostName test.com \ No newline at end of file +HostName test.com