fix: 替换过时的 X-XSS-Protection 为 Content-Security-Policy

This commit is contained in:
2026-07-10 15:27:27 +08:00
parent 276a1401f4
commit 29bdfcfb18
3 changed files with 9 additions and 6 deletions
+8 -3
View File
@@ -40,11 +40,16 @@ class EPUBSplitter:
extracted_chapters = []
for item in book.get_items_of_type(ebooklib.ITEM_DOCUMENT):
try:
# ebooklib 的 get_content() 返回 bytes
content = item.get_content().decode("utf-8")
except UnicodeDecodeError:
logger.warning("EPUB 跳过一个无法解码的章节: %s", item.get_name())
continue
try:
content = item.get_content().decode("utf-8-sig")
except UnicodeDecodeError:
try:
content = item.get_content().decode("latin-1")
except UnicodeDecodeError:
logger.warning("EPUB 跳过一个无法解码的章节: %s", item.get_name())
continue
# 用 BeautifulSoup 去标签(如果可用),否则保留原样
try: