mirror of
https://github.com/jxxghp/MoviePilot.git
synced 2026-11-04 06:15:14 +08:00
chore(deps): upgrade chardet to 7.6.0
This commit is contained in:
committed by
InfinityPacer
parent
df45df8fba
commit
8b4b5eb4fe
@@ -1,8 +1,29 @@
|
||||
from types import SimpleNamespace
|
||||
|
||||
import pytest
|
||||
from requests import Response
|
||||
|
||||
from app.adapters.network.http import RequestUtils
|
||||
|
||||
|
||||
@pytest.mark.parametrize("performance_mode", [False, True])
|
||||
def test_html_decoding_handles_incorrect_latin1_declaration(performance_mode):
|
||||
"""实际 UTF-8 内容不应被错误的 HTML 编码声明解成乱码。"""
|
||||
html = (
|
||||
'<html><head><meta charset="iso-8859-1"></head>'
|
||||
'<body>电影中文标题与高清字幕更新。</body></html>'
|
||||
)
|
||||
response = Response()
|
||||
response.status_code = 200
|
||||
response._content = html.encode("utf-8")
|
||||
|
||||
decoded = RequestUtils.get_decoded_html_content(
|
||||
response, performance_mode=performance_mode
|
||||
)
|
||||
|
||||
assert decoded == html
|
||||
|
||||
|
||||
def test_xml_decoding_prefers_xml_declaration_over_http_default():
|
||||
"""
|
||||
XML 声明应优先于 HTTP 默认编码,避免 UTF-8 RSS 标题被 latin1 类编码解坏。
|
||||
|
||||
Reference in New Issue
Block a user