From edd9221cd22614b9d06f52b16bad278201fabd01 Mon Sep 17 00:00:00 2001 From: Tithen-Firion Date: Fri, 28 Apr 2017 17:34:27 +0200 Subject: [PATCH 1/2] [utils] Fix inconsistent output of clean_html `\s` in Python 2.x doesn't match unicode whitespace characters by default --- youtube_dl/utils.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/youtube_dl/utils.py b/youtube_dl/utils.py index 91e235ff2..41bc20544 100644 --- a/youtube_dl/utils.py +++ b/youtube_dl/utils.py @@ -421,8 +421,8 @@ def clean_html(html): # Newline vs
html = html.replace('\n', ' ') - html = re.sub(r'\s*<\s*br\s*/?\s*>\s*', '\n', html) - html = re.sub(r'<\s*/\s*p\s*>\s*<\s*p[^>]*>', '\n', html) + html = re.sub(r'(?u)\s*<\s*br\s*/?\s*>\s*', '\n', html) + html = re.sub(r'(?u)<\s*/\s*p\s*>\s*<\s*p[^>]*>', '\n', html) # Strip html tags html = re.sub('<.*?>', '', html) # Replace html entities From 9222d945107411ba657dab965fab63de8e8781b9 Mon Sep 17 00:00:00 2001 From: Tithen-Firion Date: Fri, 28 Apr 2017 18:05:14 +0200 Subject: [PATCH 2/2] [test_utils] Add one more clean_html test --- test/test_utils.py | 1 + 1 file changed, 1 insertion(+) diff --git a/test/test_utils.py b/test/test_utils.py index 4cd818850..9e1808e6b 100644 --- a/test/test_utils.py +++ b/test/test_utils.py @@ -899,6 +899,7 @@ class TestUtil(unittest.TestCase): def test_clean_html(self): self.assertEqual(clean_html('a:\nb'), 'a: b') self.assertEqual(clean_html('a:\n "b"'), 'a: "b"') + self.assertEqual(clean_html('a
\xa0b'), 'a\nb') def test_intlist_to_bytes(self): self.assertEqual(