Merge branch '1.13'

This commit is contained in:
Jeff Forcier 2014-04-16 15:24:09 -04:00
commit 1b796861aa
3 changed files with 22 additions and 1 deletions

View File

@ -117,8 +117,10 @@ class SFTPClient(BaseSFTP):
def _log(self, level, msg, *args):
if isinstance(msg, list):
for m in msg:
super(SFTPClient, self)._log(level, "[chan %s] " + m, *([self.sock.get_name()] + list(args)))
self._log(level, m, *args)
else:
# escape '%' in msg (they could come from file or directory names) before logging
msg = msg.replace('%','%%')
super(SFTPClient, self)._log(level, "[chan %s] " + msg, *([self.sock.get_name()] + list(args)))
def close(self):

View File

@ -2,6 +2,8 @@
Changelog
=========
* :bug:`-` Fix logging error in sftp_client for filenames containing the '%'
character. Thanks to Antoine Brenner.
* :bug:`308` Fix regression in dsskey.py that caused sporadic signature
verification failures. Thanks to Chris Rose.
* :support:`299` Use deterministic signatures for ECDSA keys for improved

View File

@ -37,6 +37,7 @@ from paramiko.common import o777, o600, o666, o644
from tests.stub_sftp import StubServer, StubSFTPServer
from tests.loop import LoopSocket
from tests.util import test_path
import paramiko.util
from paramiko.sftp_attr import SFTPAttributes
ARTICLE = '''
@ -732,7 +733,23 @@ class SFTPTest (unittest.TestCase):
sftp.remove(target)
def test_N_file_with_percent(self):
"""
verify that we can create a file with a '%' in the filename.
( it needs to be properly escaped by _log() )
"""
self.assertTrue( paramiko.util.get_logger("paramiko").handlers, "This unit test requires logging to be enabled" )
f = sftp.open(FOLDER + '/test%file', 'w')
try:
self.assertEqual(f.stat().st_size, 0)
finally:
f.close()
sftp.remove(FOLDER + '/test%file')
if __name__ == '__main__':
SFTPTest.init_loopback()
# logging is required by test_N_file_with_percent
paramiko.util.log_to_file('test_sftp.log')
from unittest import main
main()