From 16811d5ec81125e9e3c7233b87dc028f23ca02ad Mon Sep 17 00:00:00 2001 From: Benature Date: Sun, 29 Nov 2026 01:28:07 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E6=99=BA=E8=83=BD=E7=BA=AA=E8=A6=81?= =?UTF-8?q?=E9=93=BE=E6=8E=A5=E4=B8=8D=E5=86=8D=E5=90=9E=20JSON=20?= =?UTF-8?q?=E5=BC=95=E5=8F=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- VERSION | 2 +- snooper_calendar.py | 3 ++- tests/test_calendar.py | 11 +++++++++++ 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/VERSION b/VERSION index 2779245..769ed6a 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.2.13 +0.2.14 diff --git a/snooper_calendar.py b/snooper_calendar.py index a49f5f1..23c2e23 100644 --- a/snooper_calendar.py +++ b/snooper_calendar.py @@ -14,7 +14,8 @@ class CalendarError(RuntimeError): AI_NOTES_CHAT_ID = "7391681490647744513" AI_NOTES_URL_RE = re.compile( - r"https://[A-Za-z0-9.-]+\.feishu\.cn/(?:docx|minutes)/[A-Za-z0-9]+(?:\?[^\s\x00-\x1f]*)?" + r"https://[A-Za-z0-9.-]+\.feishu\.cn/(?:docx|minutes)/[A-Za-z0-9]+" + r"(?:[?][^\s\x00-\x1f\"<>]+)?" ) TOPIC_RE = re.compile(r"Topic:\s*([^\n]+?)(?=Owner:|\Z)") diff --git a/tests/test_calendar.py b/tests/test_calendar.py index f047511..f111001 100644 --- a/tests/test_calendar.py +++ b/tests/test_calendar.py @@ -19,6 +19,17 @@ def test_extract_topic_from_card_text(): assert _extract_topic("https://efund.feishu.cn/docx/abc") == "" +def test_ai_notes_url_regex_stops_before_json_quote(): + from snooper_calendar import AI_NOTES_URL_RE + + json_text = ( + '{"text": "https://efund.feishu.cn/docx/abc123?dcuId=7&from=vc#doxcnX", ' + '"richText": {}}' + ) + urls = AI_NOTES_URL_RE.findall(json_text) + assert urls == ["https://efund.feishu.cn/docx/abc123?dcuId=7&from=vc#doxcnX"] + + def test_fetch_ai_notes_links_reads_topic_from_local_content(): tz = ZoneInfo("Asia/Shanghai") storage = SnifferStorage(url="sqlite:///:memory:")