summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeff Forcier <jeff@bitprophet.org>2016-01-19 14:47:33 -0800
committerJeff Forcier <jeff@bitprophet.org>2016-01-19 14:47:33 -0800
commit8d1fb10d58b4e80ce225bacb634f4544df8aef48 (patch)
tree6c5fc99722cb4ca6878459f55d5952d50617ac7c
parent38cc76f8586ef141fdd051a97a65dc0c7e93f645 (diff)
parent4968eaf8c92c0b59037444dcd4ce08a71e203ec2 (diff)
downloadparamiko-8d1fb10d58b4e80ce225bacb634f4544df8aef48.tar.gz
Merge branch '1.14' into 1.15
-rw-r--r--paramiko/config.py4
-rw-r--r--sites/www/changelog.rst3
-rw-r--r--tests/test_util.py9
3 files changed, 11 insertions, 5 deletions
diff --git a/paramiko/config.py b/paramiko/config.py
index 0b1345fd..e18fa4bf 100644
--- a/paramiko/config.py
+++ b/paramiko/config.py
@@ -57,7 +57,9 @@ class SSHConfig (object):
"""
host = {"host": ['*'], "config": {}}
for line in file_obj:
- line = line.rstrip('\r\n').lstrip()
+ # Strip any leading or trailing whitespace from the line.
+ # See https://github.com/paramiko/paramiko/issues/499 for more info.
+ line = line.strip()
if not line or line.startswith('#'):
continue
diff --git a/sites/www/changelog.rst b/sites/www/changelog.rst
index 972b8d43..b565e0e3 100644
--- a/sites/www/changelog.rst
+++ b/sites/www/changelog.rst
@@ -2,6 +2,9 @@
Changelog
=========
+* :bug:`499` Strip trailing/leading whitespace from lines when parsing SSH
+ config files - this brings things in line with OpenSSH behavior. Thanks to
+ Alfredo Esteban for the original report and Nick Pillitteri for the patch.
* :bug:`652` Fix behavior of ``gssapi-with-mic`` auth requests so they fail
gracefully (allowing followup via other auth methods) instead of raising an
exception. Patch courtesy of ``@jamercee``.
diff --git a/tests/test_util.py b/tests/test_util.py
index bfdc525e..a6a2c30b 100644
--- a/tests/test_util.py
+++ b/tests/test_util.py
@@ -30,6 +30,7 @@ import paramiko.util
from paramiko.util import lookup_ssh_host_config as host_config, safe_string
from paramiko.py3compat import StringIO, byte_ord, b
+# Note some lines in this configuration have trailing spaces on purpose
test_config_file = """\
Host *
User robey
@@ -110,7 +111,7 @@ class UtilTest(unittest.TestCase):
self.assertEqual(config._config,
[{'host': ['*'], 'config': {}}, {'host': ['*'], 'config': {'identityfile': ['~/.ssh/id_rsa'], 'user': 'robey'}},
{'host': ['*.example.com'], 'config': {'user': 'bjork', 'port': '3333'}},
- {'host': ['*'], 'config': {'crazy': 'something dumb '}},
+ {'host': ['*'], 'config': {'crazy': 'something dumb'}},
{'host': ['spoo.example.com'], 'config': {'crazy': 'something else'}}])
def test_3_host_config(self):
@@ -119,14 +120,14 @@ class UtilTest(unittest.TestCase):
config = paramiko.util.parse_ssh_config(f)
for host, values in {
- 'irc.danger.com': {'crazy': 'something dumb ',
+ 'irc.danger.com': {'crazy': 'something dumb',
'hostname': 'irc.danger.com',
'user': 'robey'},
- 'irc.example.com': {'crazy': 'something dumb ',
+ 'irc.example.com': {'crazy': 'something dumb',
'hostname': 'irc.example.com',
'user': 'robey',
'port': '3333'},
- 'spoo.example.com': {'crazy': 'something dumb ',
+ 'spoo.example.com': {'crazy': 'something dumb',
'hostname': 'spoo.example.com',
'user': 'robey',
'port': '3333'}