mirror of
https://github.com/yt-dlp/yt-dlp
synced 2024-12-26 21:59:08 +01:00
[parsing] support comment end tag '--!>' as suggested by github-advanced-security bot
This commit is contained in:
parent
c34166d7c8
commit
a91d9e1084
2 changed files with 3 additions and 3 deletions
|
@ -343,7 +343,7 @@ class TestParsing(unittest.TestCase):
|
|||
-----------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-----------
|
||||
this is a leftover comment --> <!-- a new comment without closing
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
here is <!-- a comment --> and <!-- another comment --> end
|
||||
here is <!-- a comment --> and <!-- another comment --!> end
|
||||
----------------^^^^^^^^^^^----------------^^^^^^^^^^^^^^^^^---------
|
||||
<script> ignore here </script> <SCRIPT> and here </SCRIPT>
|
||||
--------^^^^^^^^^^^^^-----------------------------^^^^^^^^^^---------
|
||||
|
|
|
@ -20,7 +20,7 @@ class HTMLIgnoreRanges:
|
|||
if offset in ranges:
|
||||
...
|
||||
"""
|
||||
REGEX = re.compile(r'<!--|-->|</?\s*(?:script|style)\b[^>]*>', flags=re.IGNORECASE)
|
||||
REGEX = re.compile(r'<!--|--!?>|</?\s*(?:script|style)\b[^>]*>', flags=re.IGNORECASE)
|
||||
|
||||
def __init__(self, html):
|
||||
self.html = html
|
||||
|
@ -40,7 +40,7 @@ class HTMLIgnoreRanges:
|
|||
if self._last_match is None:
|
||||
return False
|
||||
match_string = self._last_match.group()
|
||||
if match_string.startswith('</') or match_string == '-->':
|
||||
if match_string.startswith('</') or match_string in ('-->', '--!>'):
|
||||
return offset < self._last_match.start()
|
||||
return offset >= self._last_match.end()
|
||||
|
||||
|
|
Loading…
Reference in a new issue