提取验证码并返回是否语义命中。 优先语义匹配(code is 123456),降低误匹配邮件正文中随机 6 位数字的概率。
(self, content: str, pattern: str)
| 259 | return any(keyword in blob for keyword in otp_keywords) |
| 260 | |
| 261 | def _extract_otp_code(self, content: str, pattern: str) -> Tuple[Optional[str], bool]: |
| 262 | """ |
| 263 | 提取验证码并返回是否语义命中。 |
| 264 | 优先语义匹配(code is 123456),降低误匹配邮件正文中随机 6 位数字的概率。 |
| 265 | """ |
| 266 | text = str(content or "") |
| 267 | if not text: |
| 268 | return None, False |
| 269 | |
| 270 | semantic_match = re.search(OTP_CODE_SEMANTIC_PATTERN, text, re.IGNORECASE) |
| 271 | if semantic_match: |
| 272 | return semantic_match.group(1), True |
| 273 | |
| 274 | simple_match = re.search(pattern, text) |
| 275 | if simple_match: |
| 276 | return simple_match.group(1), False |
| 277 | |
| 278 | return None, False |
| 279 | |
| 280 | def _admin_headers(self) -> Dict[str, str]: |
| 281 | """构造 admin 请求头""" |
no outgoing calls
no test coverage detected