Skip to content

Commit

Permalink
Merge branch '1.14' into 1.15
Browse files Browse the repository at this point in the history
  • Loading branch information
bitprophet committed Jan 19, 2016
2 parents 38cc76f + 4968eaf commit 8d1fb10
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 @@ -57,7 +57,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

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.
* :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``.
Expand Down
9 changes: 5 additions & 4 deletions tests/test_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
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
Expand Down Expand Up @@ -110,7 +111,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 @@ -119,14 +120,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 8d1fb10

Please sign in to comment.