fix(momo): block EC404 auto-open with end-to-end URL guard
Some checks failed
CD Pipeline / deploy (push) Has been cancelled

- normalize URLs at write time (scheduler crawlers, routes) to drop
  javascript:/EC404/placeholder i_code (momo_/manual_/pchome_)
- add global click+auxclick guard in base.html and ewoooc_base.html
  that intercepts blocked MOMO URLs and redirects to safe i_code URL
- per-page dashboards reuse the same isLikelyMomoIcode validation
- /api/track_momo_link records blocked events for diagnosis
- ship sanitize_momo_urls.py to clean existing polluted DB rows

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
OoO
2026-05-02 12:00:34 +08:00
parent 026d0e7539
commit 75de76ac12
17 changed files with 1570 additions and 48 deletions

View File

@@ -14,6 +14,7 @@ from typing import List, Dict, Optional, Tuple
from dataclasses import dataclass, asdict
from difflib import SequenceMatcher
from datetime import datetime
from utils.momo_url_utils import build_momo_product_url, normalize_momo_product_url
logger = logging.getLogger(__name__)
@@ -182,6 +183,13 @@ class ProductNameParser:
# 提取產品線和關鍵字
product_line, keywords = self._extract_keywords(cleaned_name, brand)
safe_product_url = (
normalize_momo_product_url(product_url, product_id)
if source == 'momo'
else product_url
)
safe_product_url = safe_product_url or build_momo_product_url(product_id)
return ParsedProduct(
original_name=name,
brand=brand,
@@ -192,7 +200,7 @@ class ProductNameParser:
source=source,
price=price,
product_id=product_id,
product_url=product_url
product_url=safe_product_url
)
def _clean_name(self, name: str) -> str: