fix(ck): 修复令牌中的 /r 被误拆为换行并升级至 0.5.6

This commit is contained in:
yml2213
2026-11-12 13:16:48 +08:00
parent ceb31ed712
commit 90717d66d1
8 changed files with 17 additions and 31 deletions
+2 -2
View File
@@ -1,12 +1,12 @@
{ {
"name": "huya-go-frontend", "name": "huya-go-frontend",
"version": "0.5.5", "version": "0.5.6",
"lockfileVersion": 3, "lockfileVersion": 3,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "huya-go-frontend", "name": "huya-go-frontend",
"version": "0.5.5", "version": "0.5.6",
"dependencies": { "dependencies": {
"antd": "^5.26.2", "antd": "^5.26.2",
"lucide-react": "^0.468.0", "lucide-react": "^0.468.0",
+1 -1
View File
@@ -1,7 +1,7 @@
{ {
"name": "huya-go-frontend", "name": "huya-go-frontend",
"private": true, "private": true,
"version": "0.5.5", "version": "0.5.6",
"type": "module", "type": "module",
"scripts": { "scripts": {
"dev": "vite --host 127.0.0.1", "dev": "vite --host 127.0.0.1",
+1 -1
View File
@@ -1 +1 @@
a9d40923be4354a749fbbe0c2b9f924e 2ad4bd69c55591396cf10c56499e2f56
+5 -10
View File
@@ -264,6 +264,7 @@ type ScoreResult = {
type UserPrizeInfo = { type UserPrizeInfo = {
id?: number id?: number
name?: string name?: string
account?: string
score?: number score?: number
new_score?: number new_score?: number
status?: number status?: number
@@ -279,6 +280,7 @@ type RecordResult = {
uid: number uid: number
records?: UserPrizeInfo[] records?: UserPrizeInfo[]
resp?: { resp?: {
status?: number
msg?: string msg?: string
} }
error?: string error?: string
@@ -670,16 +672,9 @@ function writeSavedPrizeCache(
} }
function normalizeCookieText(text: string): string { function normalizeCookieText(text: string): string {
const normalized = text return text
.replace(/\r\n?/g, '\n') .replace(/\r\n?/g, '\n')
.replace(/\\r\\n|\\r|\\n/g, '\n') .replace(/\\r\\n|\\r|\\n/g, '\n')
const withLineBreaks =
normalized.includes('\n') || !/\/r\/n|\/r/.test(normalized)
? normalized
: normalized.replace(/\/r\/n|\/r|\/n/g, '\n')
return withLineBreaks
.split('\n') .split('\n')
.map((line) => line.trim()) .map((line) => line.trim())
.filter(Boolean) .filter(Boolean)
@@ -1995,7 +1990,7 @@ export default function Dashboard() {
minWidth: 200, minWidth: 200,
ellipsis: true, ellipsis: true,
render: (name, row) => ( render: (name, row) => (
<Space orientation="horizontal" size={6}> <Space size={6}>
{row.img ? ( {row.img ? (
<img <img
src={row.img} src={row.img}
@@ -2807,7 +2802,7 @@ export default function Dashboard() {
title: '商品', title: '商品',
dataIndex: 'name', dataIndex: 'name',
render: (name, r) => ( render: (name, r) => (
<Space orientation="horizontal" size={8}> <Space size={8}>
{r.img ? ( {r.img ? (
<img <img
src={r.img} src={r.img}
+1 -10
View File
@@ -988,22 +988,13 @@ func splitCookieLines(cookieText string) []cookieLine {
} }
func normalizeCookieText(cookieText string) string { func normalizeCookieText(cookieText string) string {
normalized := strings.NewReplacer( return strings.NewReplacer(
"\r\n", "\n", "\r\n", "\n",
"\r", "\n", "\r", "\n",
`\r\n`, "\n", `\r\n`, "\n",
`\r`, "\n", `\r`, "\n",
`\n`, "\n", `\n`, "\n",
).Replace(cookieText) ).Replace(cookieText)
if strings.Contains(normalized, "\n") ||
(!strings.Contains(normalized, "/r/n") && !strings.Contains(normalized, "/r")) {
return normalized
}
return strings.NewReplacer(
"/r/n", "\n",
"/r", "\n",
"/n", "\n",
).Replace(normalized)
} }
func requestContext(timeoutSec int) (context.Context, context.CancelFunc) { func requestContext(timeoutSec int) (context.Context, context.CancelFunc) {
+3 -3
View File
@@ -24,9 +24,9 @@ func TestSplitCookieLinesNormalizesLineBreaks(t *testing.T) {
want: []string{"ck-a", "ck-b", "ck-c", "ck-d"}, want: []string{"ck-a", "ck-b", "ck-c", "ck-d"},
}, },
{ {
name: "slash_r_line_breaks", name: "slash_r_and_n_inside_token_are_preserved",
input: "ck-a/r/nck-b/rck-c/nck-d", input: "yyuid=1; udb_cred=abc/rrZT/nXYZ",
want: []string{"ck-a", "ck-b", "ck-c", "ck-d"}, want: []string{"yyuid=1; udb_cred=abc/rrZT/nXYZ"},
}, },
{ {
name: "slash_n_only_is_preserved", name: "slash_n_only_is_preserved",
+3 -3
View File
@@ -5,10 +5,10 @@ package version
// //
// 构建时可用 ldflags 覆盖(构建脚本就是这么做的): // 构建时可用 ldflags 覆盖(构建脚本就是这么做的):
// //
// go build -ldflags "-X huya-go/internal/version.Version=0.5.4" // go build -ldflags "-X huya-go/internal/version.Version=0.5.6"
var Version = "0.5.5" var Version = "0.5.6"
// Display 返回带 v 前缀的展示版本号,例如 v0.5.4。 // Display 返回带 v 前缀的展示版本号,例如 v0.5.6。
func Display() string { func Display() string {
return "v" + Version return "v" + Version
} }
+1 -1
View File
@@ -9,7 +9,7 @@
"info": { "info": {
"companyName": "huya-go", "companyName": "huya-go",
"productName": "虎牙抢购助手", "productName": "虎牙抢购助手",
"productVersion": "0.5.5", "productVersion": "0.5.6",
"copyright": "", "copyright": "",
"comments": "虎牙活动积分兑换/抢购工具" "comments": "虎牙活动积分兑换/抢购工具"
} }