mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2026-12-01 21:36:42 +02:00
[utils] fix_xml_ampersands: Fix numeric character references (#17842)
Authored by: doe1080
This commit is contained in:
@@ -780,6 +780,9 @@ class TestUtil(unittest.TestCase):
|
||||
'&'><"')
|
||||
self.assertEqual(
|
||||
fix_xml_ampersands('Ӓ᪼'), 'Ӓ᪼')
|
||||
self.assertEqual(
|
||||
fix_xml_ampersands('😀😀'), '😀😀')
|
||||
self.assertEqual(fix_xml_ampersands('&#;&#x;'), '&#;&#x;')
|
||||
self.assertEqual(fix_xml_ampersands('&#&#'), '&#&#')
|
||||
|
||||
def test_paged_list(self):
|
||||
|
||||
@@ -1939,7 +1939,7 @@ def month_by_abbreviation(abbrev):
|
||||
def fix_xml_ampersands(xml_str):
|
||||
"""Replace all the '&' by '&' in XML"""
|
||||
return re.sub(
|
||||
r'&(?!amp;|lt;|gt;|apos;|quot;|#x[0-9a-fA-F]{,4};|#[0-9]{,4};)',
|
||||
r'&(?!amp;|lt;|gt;|apos;|quot;|#x[0-9a-fA-F]+;|#[0-9]+;)',
|
||||
'&',
|
||||
xml_str)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user