mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2024-11-21 20:46:36 -05:00
remove kebab
This commit is contained in:
parent
851229a01f
commit
a0f28f90fa
1 changed files with 1 additions and 40 deletions
|
@ -108,7 +108,7 @@ def compat_urllib_parse_unquote_to_bytes(string):
|
||||||
|
|
||||||
compat_urllib_parse_asciire = re.compile('([\x00-\x7f]+)')
|
compat_urllib_parse_asciire = re.compile('([\x00-\x7f]+)')
|
||||||
|
|
||||||
def new_compat_urllib_parse_unquote(string, encoding='utf-8', errors='replace'):
|
def compat_urllib_parse_unquote(string, encoding='utf-8', errors='replace'):
|
||||||
"""Replace %xx escapes by their single-character equivalent. The optional
|
"""Replace %xx escapes by their single-character equivalent. The optional
|
||||||
encoding and errors parameters specify how to decode percent-encoded
|
encoding and errors parameters specify how to decode percent-encoded
|
||||||
sequences into Unicode characters, as accepted by the bytes.decode()
|
sequences into Unicode characters, as accepted by the bytes.decode()
|
||||||
|
@ -142,45 +142,6 @@ def new_compat_urllib_parse_unquote(string, encoding='utf-8', errors='replace'):
|
||||||
append(bar)
|
append(bar)
|
||||||
return ''.join(res)
|
return ''.join(res)
|
||||||
|
|
||||||
def old_compat_urllib_parse_unquote(string, encoding='utf-8', errors='replace'):
|
|
||||||
if string == '':
|
|
||||||
return string
|
|
||||||
res = string.split('%')
|
|
||||||
if len(res) == 1:
|
|
||||||
return string
|
|
||||||
if encoding is None:
|
|
||||||
encoding = 'utf-8'
|
|
||||||
if errors is None:
|
|
||||||
errors = 'replace'
|
|
||||||
# pct_sequence: contiguous sequence of percent-encoded bytes, decoded
|
|
||||||
pct_sequence = b''
|
|
||||||
string = res[0]
|
|
||||||
for item in res[1:]:
|
|
||||||
try:
|
|
||||||
if not item:
|
|
||||||
raise ValueError
|
|
||||||
if not re.match('[0-9a-fA-F][0-9a-fA-F]',item[:2]):
|
|
||||||
raise ValueError
|
|
||||||
pct_sequence += item[:2].decode('hex')
|
|
||||||
rest = item[2:]
|
|
||||||
if not rest:
|
|
||||||
# This segment was just a single percent-encoded character.
|
|
||||||
# May be part of a sequence of code units, so delay decoding.
|
|
||||||
# (Stored in pct_sequence).
|
|
||||||
continue
|
|
||||||
except ValueError:
|
|
||||||
rest = '%' + item
|
|
||||||
# Encountered non-percent-encoded characters. Flush the current
|
|
||||||
# pct_sequence.
|
|
||||||
string += pct_sequence.decode(encoding, errors) + rest
|
|
||||||
pct_sequence = b''
|
|
||||||
if pct_sequence:
|
|
||||||
# Flush the final pct_sequence
|
|
||||||
string += pct_sequence.decode(encoding, errors)
|
|
||||||
return string
|
|
||||||
|
|
||||||
compat_urllib_parse_unquote = new_compat_urllib_parse_unquote
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
compat_str = unicode # Python 2
|
compat_str = unicode # Python 2
|
||||||
except NameError:
|
except NameError:
|
||||||
|
|
Loading…
Reference in a new issue