# -*- coding: utf-8 -*- r'''全仓扫描:Python 三引号字符串里嵌的 JS,有没有被 Python 吃掉的转义。 == 要找的东西 == admin.py 那个 bug 的形状是: Python 普通三引号字符串里写了 \n(反斜杠+n) -> Python 把它变成真实换行 -> JS 行注释 // 不能跨行 -> 整段 (此时还是**未经过 Python 转义**的原文) # 这还不够 —— 真正的坑在 Python 解释转义之后。 # 所以更准的办法:能用 import 的就 import,渲染出来再看。 # 不能 import 的,就退化成「源码原文」扫描,并说明局限。 scripts = re.findall(r"]*>(.*?)", text, re.S) scripts = [s for s in scripts if s.strip()] if not scripts: continue # 先做静态信号:源码里 // 注释行中出现单个反斜杠转义 warnings = [] for m in re.finditer(r"^[ \t]*//.*$", text, re.M): line = m.group(0) # 注释里出现 \n \r \t 这样的转义(单反斜杠) if re.search(r"(?