mirror of
				https://github.com/python/cpython.git
				synced 2025-11-03 23:21:29 +00:00 
			
		
		
		
	bpo-41471: Ignore invalid prefix lengths in system proxy settings on macOS (GH-22762) (GH-22773)
(cherry picked from commit 93a1ccabde)
Co-authored-by: Ronald Oussoren <ronaldoussoren@mac.com>
			
			
This commit is contained in:
		
							parent
							
								
									479553c7c1
								
							
						
					
					
						commit
						aa7b03b31b
					
				
					 3 changed files with 18 additions and 0 deletions
				
			
		| 
						 | 
					@ -1447,6 +1447,18 @@ def test_osx_proxy_bypass(self):
 | 
				
			||||||
        bypass = {'exclude_simple': True, 'exceptions': []}
 | 
					        bypass = {'exclude_simple': True, 'exceptions': []}
 | 
				
			||||||
        self.assertTrue(_proxy_bypass_macosx_sysconf('test', bypass))
 | 
					        self.assertTrue(_proxy_bypass_macosx_sysconf('test', bypass))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        # Check that invalid prefix lengths are ignored
 | 
				
			||||||
 | 
					        bypass = {
 | 
				
			||||||
 | 
					            'exclude_simple': False,
 | 
				
			||||||
 | 
					            'exceptions': [ '10.0.0.0/40', '172.19.10.0/24' ]
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        host = '172.19.10.5'
 | 
				
			||||||
 | 
					        self.assertTrue(_proxy_bypass_macosx_sysconf(host, bypass),
 | 
				
			||||||
 | 
					                        'expected bypass of %s to be True' % host)
 | 
				
			||||||
 | 
					        host = '10.0.1.5'
 | 
				
			||||||
 | 
					        self.assertFalse(_proxy_bypass_macosx_sysconf(host, bypass),
 | 
				
			||||||
 | 
					                        'expected bypass of %s to be False' % host)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def check_basic_auth(self, headers, realm):
 | 
					    def check_basic_auth(self, headers, realm):
 | 
				
			||||||
        with self.subTest(realm=realm, headers=headers):
 | 
					        with self.subTest(realm=realm, headers=headers):
 | 
				
			||||||
            opener = OpenerDirector()
 | 
					            opener = OpenerDirector()
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -2596,6 +2596,11 @@ def ip2num(ipAddr):
 | 
				
			||||||
                mask = 8 * (m.group(1).count('.') + 1)
 | 
					                mask = 8 * (m.group(1).count('.') + 1)
 | 
				
			||||||
            else:
 | 
					            else:
 | 
				
			||||||
                mask = int(mask[1:])
 | 
					                mask = int(mask[1:])
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            if mask < 0 or mask > 32:
 | 
				
			||||||
 | 
					                # System libraries ignore invalid prefix lengths
 | 
				
			||||||
 | 
					                continue
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            mask = 32 - mask
 | 
					            mask = 32 - mask
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            if (hostIP >> mask) == (base >> mask):
 | 
					            if (hostIP >> mask) == (base >> mask):
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1 @@
 | 
				
			||||||
 | 
					Ignore invalid prefix lengths in system proxy excludes.
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue