mirror of
https://git.mirrors.martin98.com/https://github.com/sub-store-org/Sub-Store.git
synced 2025-08-11 16:09:01 +08:00
fix: 修复 Clash 节点名为 binary 的情况
This commit is contained in:
parent
468d136f0e
commit
a4384f4f13
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "sub-store",
|
||||
"version": "2.14.233",
|
||||
"version": "2.14.235",
|
||||
"description": "Advanced Subscription Manager for QX, Loon, Surge, Stash and ShadowRocket.",
|
||||
"main": "src/main.js",
|
||||
"scripts": {
|
||||
|
@ -1,6 +1,12 @@
|
||||
import YAML from '@/utils/yaml';
|
||||
import download from '@/utils/download';
|
||||
import { isIPv4, isIPv6, isValidPortNumber, isNotBlank } from '@/utils';
|
||||
import {
|
||||
isIPv4,
|
||||
isIPv6,
|
||||
isValidPortNumber,
|
||||
isNotBlank,
|
||||
utf8ArrayToStr,
|
||||
} from '@/utils';
|
||||
import PROXY_PROCESSORS, { ApplyProcessor } from './processors';
|
||||
import PROXY_PREPROCESSORS from './preprocessors';
|
||||
import PROXY_PRODUCERS from './producers';
|
||||
@ -370,6 +376,18 @@ function lastParse(proxy) {
|
||||
}
|
||||
}
|
||||
}
|
||||
if (typeof proxy.name !== 'string') {
|
||||
try {
|
||||
if (proxy.name?.data) {
|
||||
proxy.name = Buffer.from(proxy.name.data).toString('utf8');
|
||||
} else {
|
||||
proxy.name = utf8ArrayToStr(proxy.name);
|
||||
}
|
||||
} catch (e) {
|
||||
$.error(`proxy.name decode failed\nReason: ${e}`);
|
||||
proxy.name = `${proxy.type} ${proxy.server}:${proxy.port}`;
|
||||
}
|
||||
}
|
||||
return proxy;
|
||||
}
|
||||
|
||||
|
@ -35,6 +35,53 @@ function getIfPresent(obj, defaultValue) {
|
||||
return isPresent(obj) ? obj : defaultValue;
|
||||
}
|
||||
|
||||
const utf8ArrayToStr =
|
||||
typeof TextDecoder !== 'undefined'
|
||||
? (v) => new TextDecoder().decode(new Uint8Array(v))
|
||||
: (function () {
|
||||
var charCache = new Array(128); // Preallocate the cache for the common single byte chars
|
||||
var charFromCodePt = String.fromCodePoint || String.fromCharCode;
|
||||
var result = [];
|
||||
|
||||
return function (array) {
|
||||
var codePt, byte1;
|
||||
var buffLen = array.length;
|
||||
|
||||
result.length = 0;
|
||||
|
||||
for (var i = 0; i < buffLen; ) {
|
||||
byte1 = array[i++];
|
||||
|
||||
if (byte1 <= 0x7f) {
|
||||
codePt = byte1;
|
||||
} else if (byte1 <= 0xdf) {
|
||||
codePt = ((byte1 & 0x1f) << 6) | (array[i++] & 0x3f);
|
||||
} else if (byte1 <= 0xef) {
|
||||
codePt =
|
||||
((byte1 & 0x0f) << 12) |
|
||||
((array[i++] & 0x3f) << 6) |
|
||||
(array[i++] & 0x3f);
|
||||
} else if (String.fromCodePoint) {
|
||||
codePt =
|
||||
((byte1 & 0x07) << 18) |
|
||||
((array[i++] & 0x3f) << 12) |
|
||||
((array[i++] & 0x3f) << 6) |
|
||||
(array[i++] & 0x3f);
|
||||
} else {
|
||||
codePt = 63; // Cannot convert four byte code points, so use "?" instead
|
||||
i += 3;
|
||||
}
|
||||
|
||||
result.push(
|
||||
charCache[codePt] ||
|
||||
(charCache[codePt] = charFromCodePt(codePt)),
|
||||
);
|
||||
}
|
||||
|
||||
return result.join('');
|
||||
};
|
||||
})();
|
||||
|
||||
export {
|
||||
isIPv4,
|
||||
isIPv6,
|
||||
@ -43,4 +90,5 @@ export {
|
||||
getIfNotBlank,
|
||||
isPresent,
|
||||
getIfPresent,
|
||||
utf8ArrayToStr,
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user