Escape URLs in `sanitized_Request`, not `sanitize_url` d2558234cf5dd12d6896eed5427b7d...
authorpukkandan <pukkandan.ytdlp@gmail.com>
Tue, 1 Jun 2021 12:35:41 +0000 (18:05 +0530)
committerdirkf <fieldhouse@gmx.net>
Mon, 20 Feb 2023 20:27:25 +0000 (20:27 +0000)
test/test_utils.py
youtube_dl/extractor/generic.py
youtube_dl/utils.py

index 9d364c86381ccb17f3578d9f8fdb212804c2cff2..ea2b96ed2a88a86b8700df9b5459ae127eb6e6b3 100644 (file)
@@ -250,6 +250,7 @@ class TestUtil(unittest.TestCase):
         self.assertEqual(sanitize_url('httpss://foo.bar'), 'https://foo.bar')
         self.assertEqual(sanitize_url('rmtps://foo.bar'), 'rtmps://foo.bar')
         self.assertEqual(sanitize_url('https://foo.bar'), 'https://foo.bar')
+        self.assertEqual(sanitize_url('foo bar'), 'foo bar')
 
     def test_expand_path(self):
         def env(var):
index 0e473e952cef274497532019ab053406c87646a1..b01900afaadea8781548819b3e6c77ae1bd9067b 100644 (file)
@@ -2320,6 +2320,25 @@ class GenericIE(InfoExtractor):
                 'height': 720,
                 'age_limit': 18,
             },
+        }, {
+            # would like to use the yt-dl test video but searching for
+            # '"\'/\\รคโ†ญ๐•' fails, so using an old vid from YouTube Korea
+            'note': 'Test default search',
+            'url': 'Shorts๋กœ ํ—ˆ๋ฝ ํ•„์š”์—†์ด ๋†€์ž! (BTSํŽธ)',
+            'info_dict': {
+                'id': 'usDGO4Zb-dc',
+                'ext': 'mp4',
+                'title': 'YouTube Shorts๋กœ ํ—ˆ๋ฝ ํ•„์š”์—†์ด ๋†€์ž! (BTSํŽธ)',
+                'description': 'md5:96e31607eba81ab441567b5e289f4716',
+                'upload_date': '20211107',
+                'uploader': 'YouTube Korea',
+                'location': '๋Œ€ํ•œ๋ฏผ๊ตญ',
+            },
+            'params': {
+                'default_search': 'ytsearch',
+                'skip_download': True,
+            },
+            'expected_warnings': ['uploader id'],
         },
     ]
 
index 4edbfa27ba68fb084036ce2ba26b6ca1ea5e26d5..761edcd4962efd23f958b1c5af3ad8f21c7b0d46 100644 (file)
@@ -2176,11 +2176,11 @@ def sanitize_url(url):
     for mistake, fixup in COMMON_TYPOS:
         if re.match(mistake, url):
             return re.sub(mistake, fixup, url)
-    return escape_url(url)
+    return url
 
 
 def sanitized_Request(url, *args, **kwargs):
-    return compat_urllib_request.Request(sanitize_url(url), *args, **kwargs)
+    return compat_urllib_request.Request(escape_url(sanitize_url(url)), *args, **kwargs)
 
 
 def expand_path(s):