fix(plugin): detect anti-crawler challenge in non-2xx responses - #2579
Merged
Predidit merged 2 commits intoSep 30, 2026
Merged
Conversation
Owner
|
确定在这个PR后我们可以访问hanime1吗,看上去需要更多的工作 |
Author
Owner
|
Hi,很抱歉之前错过了这个PR 注意到我们现在在检测 cf-mitigated: challenge ,当前实现可以通过 cloudflare challenge 吗 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


描述
为了更好的适配 Hanime 网站的特性,我尝试了修复 XPath 规则在启用 antiCrawlerConfig 时,无法处理非 2xx Challenge 响应的问题
_目前当目标站点返回 HTTP 403 / 429 / 503 等验证页时,Dio 会先将响应转换成 NetworkExceptionType.badResponse,导致响应正文没有机会进入 XPath 的 captcha 检测逻辑,因此不会触发现有的 WebView 验证流程。
这个修改会在 XPath 搜索请求失败且错误类型为 badResponse 时,继续检查 Dio 中保留下来的响应内容。如果响应头存在 cf-mitigated: challenge,或者响应正文能够被当前规则配置的 anti-crawler 检测器识别,就将该错误转换为 CaptchaRequiredException,从而继续使用现有验证码流程。
API 搜索模式不会走这套转换逻辑,普通非 Challenge 的 HTTP 错误仍保持原有行为。
同时补充了对应测试,覆盖:
XPath 非 2xx Challenge 响应触发验证码流程
cf-mitigated: challenge 响应头识别
普通非 Challenge badResponse 保持原错误
API 模式不会错误进入 captcha 流程_
关联的 Issues
#2578
PR 类型
AI 辅助开发
AI 辅助模型: OpenAI GPT-5.6 Sol
提交前检查
附注
已通过:
flutter testflutter analyze --no-fatal-infos --fatal-warnings并已在 Windows 构建中进行验证。