Skip to content

Commit

Permalink
Merge branch '1.13' into 1.14
Browse files Browse the repository at this point in the history
  • Loading branch information
bitprophet committed Jan 19, 2016
2 parents a1fbc37 + 1919014 commit 4968eaf
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
4 changes: 3 additions & 1 deletion paramiko/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,9 @@ def parse(self, file_obj):
"""
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:
Expand Down
3 changes: 3 additions & 0 deletions sites/www/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 5 additions & 4 deletions tests/test_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@

from tests.util import ParamikoTest

# Note some lines in this configuration have trailing spaces on purpose
test_config_file = """\
Host *
User robey
Expand Down Expand Up @@ -106,7 +107,7 @@ def test_2_parse_config(self):
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):
Expand All @@ -115,14 +116,14 @@ def test_3_host_config(self):
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'}
Expand Down

0 comments on commit 4968eaf

Please sign in to comment.