OSDN Git Service

v2rayA: fix path in patches
[v2raya/v2raya-openwrt.git] / v2raya / patches / 002-fix-resolving-subscription-for-line-breaked-base64-s.patch
1 From 4a9347e0cc5effe67399931c804bcef1114d535f Mon Sep 17 00:00:00 2001
2 From: =?UTF-8?q?=E9=AB=98=E6=B8=90=E7=A6=BB?=
3  <zhangyibo.114514@bytedance.com>
4 Date: Tue, 8 Feb 2022 17:52:56 +0800
5 Subject: [PATCH] fix: resolving subscription for line-breaked base64 string
6  (#406)
7
8 ---
9  service/common/crypto.go | 3 ++-
10  1 file changed, 2 insertions(+), 1 deletion(-)
11
12 diff --git a/common/crypto.go b/common/crypto.go
13 index b9e5173..4a067e8 100644
14 --- a/common/crypto.go
15 +++ b/common/crypto.go
16 @@ -44,10 +44,11 @@ func Base64StdDecode(s string) (string, error) {
17         return string(raw), err
18  }
19  
20 -// 封装base64.URLEncoding进行解码,加入了长度补全。当error时,返回输入和err
21 +// 封装base64.URLEncoding进行解码,加入了长度补全,换行删除。当error时,返回输入和err
22  func Base64URLDecode(s string) (string, error) {
23         s = strings.TrimSpace(s)
24         saver := s
25 +       s = strings.ReplaceAll(strings.ReplaceAll(s, "\n", ""), "\r", "")
26         if len(s)%4 > 0 {
27                 s += strings.Repeat("=", 4-len(s)%4)
28         }
29 -- 
30 2.20.1
31