fix: Cookie 登录剪贴板导入兼容标准 key=value 格式#2653
Open
Schweik7 wants to merge 1 commit into
Open
Conversation
原导入逻辑要求「每行一个、冒号分隔、且至少两行」,无法识别浏览器/ 插件导出的标准 cookie 格式(key=value; key=value),导致从剪贴板 导入几乎总是失败。 改进 importCookie()/handleCookie(): - 条目分隔同时支持换行与分号,键值分隔同时支持 ':' 与 '='; - 去除多余空格用 trim 而非删除所有空格,并放宽单行限制; - 只在「未识别到任何有效 cookie」时提示一次,不再每行误报。 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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.
问题
Cookie 登录页的「从剪贴板导入」按钮解析过于严格,只接受每行一个、冒号分隔、且至少两行的格式:
\n分割且要求length >= 2(单行直接拒绝);:分割,要求正好两段;=/;的标准 cookie 串(浏览器、Cookie 导出插件、网页控制台document.cookie的通用格式)完全无法识别。实际用户最常拿到的就是
ipb_member_id=...; ipb_pass_hash=...; igneous=...这种单行分号格式,导致导入几乎总是失败。改动(
CookieSignInScene.java)split("[\n; ]");:和=(取第一个出现的);trim()去首尾空格(替代原来删除全部空格),放宽单行限制;handleCookie改为返回是否命中,仅在整体没识别到任何有效 cookie 时提示一次,不再每行误报 toast;yay)安全忽略。兼容性:原「冒号 + 每行一个」格式继续可用。
现在这些都能导入
已本地编译通过(assembleDebug),debug 包真机验证。
🤖 Generated with Claude Code