Skip to content

Commit ef2d6be

Browse files
committed
feat: 预处理支持 Base64 兜底
1 parent 04e12a4 commit ef2d6be

File tree

2 files changed

+29
-2
lines changed

2 files changed

+29
-2
lines changed

backend/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "sub-store",
3-
"version": "2.19.45",
3+
"version": "2.19.46",
44
"description": "Advanced Subscription Manager for QX, Loon, Surge, Stash and Shadowrocket.",
55
"main": "src/main.js",
66
"scripts": {

backend/src/core/proxy-utils/preprocessors/index.js

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,26 @@ function Base64Encoded() {
5050
return { name, test, parse };
5151
}
5252

53+
function fallbackBase64Encoded() {
54+
const name = 'Fallback Base64 Pre-processor';
55+
56+
const test = function (raw) {
57+
return true;
58+
};
59+
const parse = function (raw) {
60+
const decoded = Base64.decode(raw);
61+
if (!/^\w+(:\/\/|\s*?=\s*?)\w+/m.test(decoded)) {
62+
$.error(
63+
`Fallback Base64 Pre-processor error: decoded line does not start with protocol`,
64+
);
65+
return raw;
66+
}
67+
68+
return decoded;
69+
};
70+
return { name, test, parse };
71+
}
72+
5373
function Clash() {
5474
const name = 'Clash Pre-processor';
5575
const test = function (raw) {
@@ -163,4 +183,11 @@ function FullConfig() {
163183
return { name, test, parse };
164184
}
165185

166-
export default [HTML(), Clash(), Base64Encoded(), SSD(), FullConfig()];
186+
export default [
187+
HTML(),
188+
Clash(),
189+
Base64Encoded(),
190+
SSD(),
191+
FullConfig(),
192+
fallbackBase64Encoded(),
193+
];

0 commit comments

Comments
 (0)