Merge pull request #439 from notmasteryet/tree-13
Allow test.py serve files with spaces in the name
This commit is contained in:
		
						commit
						76caa3f3a7
					
				| @ -126,14 +126,15 @@ class PDFTestHandler(BaseHTTPRequestHandler): | |||||||
|         self.wfile.write("<html><body><h1>PDFs of " + path + "</h1>\n") |         self.wfile.write("<html><body><h1>PDFs of " + path + "</h1>\n") | ||||||
|         for filename in os.listdir(location): |         for filename in os.listdir(location): | ||||||
|           if filename.lower().endswith('.pdf'): |           if filename.lower().endswith('.pdf'): | ||||||
|             self.wfile.write("<a href='/web/viewer.html?file=" + path + filename + "' target=pdf>" + |             self.wfile.write("<a href='/web/viewer.html?file=" + | ||||||
|  |               urllib.quote_plus(path + filename, '/') + "' target=pdf>" + | ||||||
|               filename + "</a><br>\n") |               filename + "</a><br>\n") | ||||||
|         self.wfile.write("</body></html>") |         self.wfile.write("</body></html>") | ||||||
| 
 | 
 | ||||||
|     def do_GET(self): |     def do_GET(self): | ||||||
|         url = urlparse(self.path) |         url = urlparse(self.path) | ||||||
|         # Ignore query string |         # Ignore query string | ||||||
|         path, _ = url.path, url.query |         path, _ = urllib.unquote_plus(url.path), url.query | ||||||
|         path = os.path.abspath(os.path.realpath(DOC_ROOT + os.sep + path)) |         path = os.path.abspath(os.path.realpath(DOC_ROOT + os.sep + path)) | ||||||
|         prefix = os.path.commonprefix(( path, DOC_ROOT )) |         prefix = os.path.commonprefix(( path, DOC_ROOT )) | ||||||
|         _, ext = os.path.splitext(path.lower()) |         _, ext = os.path.splitext(path.lower()) | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user