summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael P. Soulier <msoulier@digitaltorque.ca>2022-11-26 19:51:30 -0500
committerMichael P. Soulier <msoulier@digitaltorque.ca>2022-11-26 19:51:30 -0500
commit5cbc1b4f5f2e3c6a5a136dea19a918f58258e3f3 (patch)
tree6847dcbb56d549c859d3b8eeabf6776c516e0876
parent7c62b3472627f4bfe85e359d80d2b9eff2588ce7 (diff)
downloadtftpy-5cbc1b4f5f2e3c6a5a136dea19a918f58258e3f3.tar.gz
Added spaces to directory names.
-rw-r--r--t/test.py27
1 files changed, 26 insertions, 1 deletions
diff --git a/t/test.py b/t/test.py
index 22502ab..6c45391 100644
--- a/t/test.py
+++ b/t/test.py
@@ -209,7 +209,7 @@ class TestTftpyState(unittest.TestCase):
@contextmanager
def dummyServerDir(self):
tmpdir = mkdtemp()
- for dirname in ("foo", "foo-private", "other"):
+ for dirname in ("foo", "foo-private", "other", "with spaces"):
os.mkdir(os.path.join(tmpdir, dirname))
with open(os.path.join(tmpdir, dirname, "bar"), "w") as w:
w.write("baz")
@@ -608,6 +608,31 @@ class TestTftpyState(unittest.TestCase):
server.stop(now=False)
server_thread.join()
+class TestTftpyMisc(unittest.TestCase):
+ def testDirectoriesWithSpaces(self):
+ """Handle the evil directory names."""
+ root = "/tmp/bad dirname"
+ if not os.path.exists(root):
+ os.mkdir(root)
+ home = os.path.dirname(os.path.abspath(__file__))
+ filename = "640KBFILE"
+ input_path = os.path.join(home, filename)
+ print("input_path is", input_path)
+ server = tftpy.TftpServer(root)
+ client = tftpy.TftpClient("localhost", 20001)
+ # Fork a server and run the client in this process.
+ child_pid = os.fork()
+ if child_pid:
+ # parent - let the server start
+ try:
+ time.sleep(1)
+ client.upload("640KBFILE", input_path)
+ finally:
+ os.kill(child_pid, 15)
+ os.waitpid(child_pid, 0)
+
+ else:
+ server.listen("localhost", 20001)
if __name__ == "__main__":
unittest.main()