summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeff Forcier <jeff@bitprophet.org>2016-01-19 14:46:46 -0800
committerJeff Forcier <jeff@bitprophet.org>2016-01-19 14:46:46 -0800
commit4968eaf8c92c0b59037444dcd4ce08a71e203ec2 (patch)
tree55fc99130c78131b8e911de482d8afe2084080b4
parenta1fbc37779f9bb1ee152057e7110d5b1c77a863c (diff)
parent1919014fa649d32dec4039f2b8c115233c082418 (diff)
downloadparamiko-4968eaf8c92c0b59037444dcd4ce08a71e203ec2.tar.gz
Merge branch '1.13' into 1.14
-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 5c2efdcc..6553691b 100644
--- a/paramiko/config.py
+++ b/paramiko/config.py
@@ -55,7 +55,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
if '=' in line:
diff --git a/sites/www/changelog.rst b/sites/www/changelog.rst
index 1926ab17..bad37089 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.
* :support:`636` Clean up and enhance the README (and rename it to
``README.rst`` from just ``README``). Thanks to ``@LucasRMehl``.
* :bug:`401` Fix line number reporting in log output regarding invalid
diff --git a/tests/test_util.py b/tests/test_util.py
index 7889aa7a..25e447bb 100644
--- a/tests/test_util.py
+++ b/tests/test_util.py
@@ -31,6 +31,7 @@ from paramiko.py3compat import StringIO, byte_ord, b
from tests.util import ParamikoTest
+# Note some lines in this configuration have trailing spaces on purpose
test_config_file = """\
Host *
User robey
@@ -106,7 +107,7 @@ class UtilTest(ParamikoTest):
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):
@@ -115,14 +116,14 @@ class UtilTest(ParamikoTest):
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'}