Files
MoviePilot/app/application/download/validation.py
DDSRem 2de976f6b3 Merge pull request #7050 from DDSRem-Dev/codex-comment-migration
docs: 统一全项目中文注释和结构化契约说明
2026-10-17 19:26:29 +08:00

18 lines
388 B
Python
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
"""
下载应用服务共享的输入校验。
"""
from __future__ import annotations
import re
_TORRENT_HASH_PATTERN = re.compile(r"^[0-9a-fA-F]{40}$")
def validate_torrent_hash(hash_value: str) -> None:
"""
校验 BitTorrent v1 Hash,拒绝模糊任务定位。
"""
if not _TORRENT_HASH_PATTERN.fullmatch(hash_value):
raise ValueError("hash 格式无效")