Skip to content

Commit

Permalink
feat: Base64 Pre-processor 检测解码是否正常
Browse files Browse the repository at this point in the history
  • Loading branch information
xream committed Jan 8, 2025
1 parent 7501250 commit 589a6bf
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
2 changes: 1 addition & 1 deletion backend/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "sub-store",
"version": "2.16.4",
"version": "2.16.5",
"description": "Advanced Subscription Manager for QX, Loon, Surge, Stash and ShadowRocket.",
"main": "src/main.js",
"scripts": {
Expand Down
12 changes: 10 additions & 2 deletions backend/src/core/proxy-utils/preprocessors/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { safeLoad } from '@/utils/yaml';
import { Base64 } from 'js-base64';
import $ from '@/core/app';

function HTML() {
const name = 'HTML';
Expand Down Expand Up @@ -35,8 +36,15 @@ function Base64Encoded() {
);
};
const parse = function (raw) {
raw = Base64.decode(raw);
return raw;
const decoded = Base64.decode(raw);
if (!/^\w+:\/\/\w+/m.test(decoded)) {
$.error(
`Base64 Pre-processor error: decoded line does not start with protocol`,
);
return raw;
}

return decoded;
};
return { name, test, parse };
}
Expand Down

0 comments on commit 589a6bf

Please sign in to comment.