From 7593e054b724af6ced2c618ef981558f6350f8f0 Mon Sep 17 00:00:00 2001 From: William Date: Tue, 30 Jun 2026 11:38:47 +0600 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=20POP=20=E7=AD=BE?= =?UTF-8?q?=E5=90=8D=20percentEncode=20=E4=BD=BF=E7=94=A8=20Unicode=20?= =?UTF-8?q?=E5=AD=97=E6=AF=8D=E9=9B=86=E5=AF=BC=E8=87=B4=E9=9D=9E=20ASCII?= =?UTF-8?q?=20=E5=AD=97=E7=AC=A6=E6=9C=AA=E7=BC=96=E7=A0=81=E7=9A=84?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Sources/VODManager/Services/VODSignature.swift | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/apps/macos/VODManager/Sources/VODManager/Services/VODSignature.swift b/apps/macos/VODManager/Sources/VODManager/Services/VODSignature.swift index 5692538..b2436b8 100644 --- a/apps/macos/VODManager/Sources/VODManager/Services/VODSignature.swift +++ b/apps/macos/VODManager/Sources/VODManager/Services/VODSignature.swift @@ -26,6 +26,8 @@ struct VODSignature { let stringToSign = "\(method)&%2F&\(percentEncode(canonicalQuery))" + print("[VODSignature] stringToSign: \(stringToSign)") + guard let keyData = "\(accessKeySecret)&".data(using: .utf8) else { throw VODSignatureError.invalidKey } @@ -40,7 +42,15 @@ struct VODSignature { } private static func percentEncode(_ value: String) -> String { - let allowed = CharacterSet(charactersIn: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_.~") - return value.addingPercentEncoding(withAllowedCharacters: allowed) ?? value + let allowed = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_.~" + var result = "" + for char in value.utf8 { + if allowed.utf8.contains(char) { + result.append(Character(UnicodeScalar(char))) + } else { + result.append(String(format: "%%%02X", char)) + } + } + return result } }