mirror of
				https://github.com/yt-dlp/yt-dlp.git
				synced 2025-10-30 22:25:19 +00:00 
			
		
		
		
	[utils] Improve cookie files support
+ Add support for UTF-8 in cookie files * Skip malformed cookie file entries instead of crashing (invalid entry len, invalid expires at)
This commit is contained in:
		| @@ -39,6 +39,13 @@ class TestYoutubeDLCookieJar(unittest.TestCase): | ||||
|         assert_cookie_has_value('HTTPONLY_COOKIE') | ||||
|         assert_cookie_has_value('JS_ACCESSIBLE_COOKIE') | ||||
|  | ||||
|     def test_malformed_cookies(self): | ||||
|         cookiejar = YoutubeDLCookieJar('./test/testdata/cookies/malformed_cookies.txt') | ||||
|         cookiejar.load(ignore_discard=True, ignore_expires=True) | ||||
|         # Cookies should be empty since all malformed cookie file entries | ||||
|         # will be ignored | ||||
|         self.assertFalse(cookiejar._cookies) | ||||
|  | ||||
|  | ||||
| if __name__ == '__main__': | ||||
|     unittest.main() | ||||
|   | ||||
							
								
								
									
										9
									
								
								test/testdata/cookies/malformed_cookies.txt
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										9
									
								
								test/testdata/cookies/malformed_cookies.txt
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,9 @@ | ||||
| # Netscape HTTP Cookie File | ||||
| # http://curl.haxx.se/rfc/cookie_spec.html | ||||
| # This is a generated file!  Do not edit. | ||||
|  | ||||
| # Cookie file entry with invalid number of fields - 6 instead of 7 | ||||
| www.foobar.foobar	FALSE	/	FALSE	0	COOKIE | ||||
|  | ||||
| # Cookie file entry with invalid expires at | ||||
| www.foobar.foobar	FALSE	/	FALSE	1.7976931348623157e+308	COOKIE	VALUE | ||||
		Reference in New Issue
	
	Block a user
	 Sergey M․
					Sergey M․