mirror of
				https://github.com/python/cpython.git
				synced 2025-10-31 05:31:20 +00:00 
			
		
		
		
	Fix Issue11474 - fix url2pathname() handling of '/C|/' on Windows
This commit is contained in:
		
							parent
							
								
									95cd91c17f
								
							
						
					
					
						commit
						2d2ea1b431
					
				
					 3 changed files with 25 additions and 1 deletions
				
			
		|  | @ -30,6 +30,9 @@ def url2pathname(url): | |||
|     for comp in components: | ||||
|         if comp: | ||||
|             path = path + '\\' + urllib.parse.unquote(comp) | ||||
|     # Issue #11474 - handing url such as |c/| | ||||
|     if path.endswith(':') and url.endswith('/'): | ||||
|         path += '\\' | ||||
|     return path | ||||
| 
 | ||||
| def pathname2url(p): | ||||
|  |  | |||
|  | @ -9,6 +9,7 @@ | |||
| import unittest | ||||
| from test import support | ||||
| import os | ||||
| import sys | ||||
| import tempfile | ||||
| import warnings | ||||
| 
 | ||||
|  | @ -995,6 +996,23 @@ def test_quoting(self): | |||
|                          "url2pathname() failed; %s != %s" % | ||||
|                          (expect, result)) | ||||
| 
 | ||||
|     @unittest.skipUnless(sys.platform == 'win32', | ||||
|                          'test specific to the urllib.url2path function.') | ||||
|     def test_ntpath(self): | ||||
|         given = ('/C:/', '///C:/', '/C|//') | ||||
|         expect = 'C:\\' | ||||
|         for url in given: | ||||
|             result = urllib.request.url2pathname(url) | ||||
|             self.assertEqual(expect, result, | ||||
|                              'urllib.request..url2pathname() failed; %s != %s' % | ||||
|                              (expect, result)) | ||||
|         given = '///C|/path' | ||||
|         expect = 'C:\\path' | ||||
|         result = urllib.request.url2pathname(given) | ||||
|         self.assertEqual(expect, result, | ||||
|                          'urllib.request.url2pathname() failed; %s != %s' % | ||||
|                          (expect, result)) | ||||
| 
 | ||||
| class Utility_Tests(unittest.TestCase): | ||||
|     """Testcase to test the various utility functions in the urllib.""" | ||||
| 
 | ||||
|  |  | |||
|  | @ -51,6 +51,9 @@ Core and Builtins | |||
| Library | ||||
| ------- | ||||
| 
 | ||||
| - Issue #11474: Fix the bug with url2pathname() handling of '/C|/' on Windows. | ||||
|   Patch by Santoso Wijaya. | ||||
| 
 | ||||
| - Issue #9233: Fix json to work properly even when _json is not available. | ||||
| 
 | ||||
| - Issue #11703: urllib2.geturl() does not return correct url when the original | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Senthil Kumaran
						Senthil Kumaran