[or-cvs] [torflow/master 36/92] Safer filename building, stopped blindly truncating strings. Also, lstrip doesn't do what I thought it did
mikeperry at torproject.org
mikeperry at torproject.org
Sat Aug 21 05:13:59 UTC 2010
Author: John M. Schanck <john at anomos.info>
Date: Tue, 27 Jul 2010 17:03:27 -0400
Subject: Safer filename building, stopped blindly truncating strings. Also, lstrip doesn't do what I thought it did
Commit: 8900e7c808e83de12ddea5638f2160db7b002a42
---
NetworkScanners/ExitAuthority/libsoat.py | 6 +++---
NetworkScanners/ExitAuthority/soat.py | 10 +++++-----
2 files changed, 8 insertions(+), 8 deletions(-)
diff --git a/NetworkScanners/ExitAuthority/libsoat.py b/NetworkScanners/ExitAuthority/libsoat.py
index 64c76f5..d04f775 100644
--- a/NetworkScanners/ExitAuthority/libsoat.py
+++ b/NetworkScanners/ExitAuthority/libsoat.py
@@ -684,10 +684,10 @@ class DataHandler:
def __resultFilename(self, result):
address = ''
- if result.__class__.__name__ == 'HtmlTestResult' or result.__class__.__name__ == 'HttpTestResult':
- address = DataHandler.safeFilename(result.site[7:])
+ if result.__class__.__name__ in ('HtmlTestResult', 'HttpTestResult'):
+ address = DataHandler.safeFilename(result.site.replace('http://',''))
elif result.__class__.__name__ == 'SSLTestResult':
- address = DataHandler.safeFilename(result.site[8:])
+ address = DataHandler.safeFilename(result.site.replace('https://','')
elif 'TestResult' in result.__class__.__name__:
address = DataHandler.safeFilename(result.site)
else:
diff --git a/NetworkScanners/ExitAuthority/soat.py b/NetworkScanners/ExitAuthority/soat.py
index 30508b5..cb3215a 100755
--- a/NetworkScanners/ExitAuthority/soat.py
+++ b/NetworkScanners/ExitAuthority/soat.py
@@ -968,7 +968,7 @@ class BaseHTTPTest(Test):
''' check whether a http connection to a given address is molested '''
# an address representation acceptable for a filename
- address_file = DataHandler.safeFilename(address[7:])
+ address_file = DataHandler.safeFilename(address.replace('http://',''))
content_prefix = http_content_dir+address_file
# Keep a copy of the cookie jar before mods for refetch or
@@ -1274,7 +1274,7 @@ class BaseHTTPTest(Test):
def _check_http_worker(self, address, http_ret):
(mime_type,pcontent,psha1sum,content,sha1sum,content_new,sha1sum_new,exit_node) = http_ret
- address_file = DataHandler.safeFilename(address[7:])
+ address_file = DataHandler.safeFilename(address.replace('http://',''))
content_prefix = http_content_dir+address_file
failed_prefix = http_failed_dir+address_file
@@ -1488,7 +1488,7 @@ class BaseHTMLTest(BaseHTTPTest):
else:
return self._check_http_worker(address, http_ret)
- address_file = DataHandler.safeFilename(address[7:])
+ address_file = DataHandler.safeFilename(address.replace('http://',''))
content_prefix = http_content_dir+address_file
failed_prefix = http_failed_dir+address_file
@@ -1543,7 +1543,7 @@ class BaseHTMLTest(BaseHTTPTest):
return self._check_http_worker(address, http_ret)
# an address representation acceptable for a filename
- address_file = DataHandler.safeFilename(address[7:])
+ address_file = DataHandler.safeFilename(address.replace('http://',''))
content_prefix = http_content_dir+address_file
failed_prefix = http_failed_dir+address_file
@@ -1718,7 +1718,7 @@ class BaseSSLTest(Test):
plog('INFO', 'Conducting an ssl test with destination ' + address)
# an address representation acceptable for a filename (first 20 chars excluding www.)
- shortaddr = address.lstrip('www.')[:min(len(address), 20)]
+ shortaddr = address.replace('www.','',1)[:min(len(address), 20)]
address_file = DataHandler.safeFilename(shortaddr)
ssl_file_name = ssl_certs_dir + address_file + '.ssl'
--
1.7.1
More information about the tor-commits
mailing list