Skip to content

Commit 7d60aed

Browse files
committed
feat: 优化 Surge ws 传输层引号解析
1 parent e20d0c1 commit 7d60aed

3 files changed

Lines changed: 5 additions & 5 deletions

File tree

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.75",
3+
"version": "2.19.76",
44
"description": "Advanced Subscription Manager for QX, Loon, Surge, Stash and Shadowrocket.",
55
"main": "src/main.js",
66
"scripts": {

backend/src/core/proxy-utils/parsers/peggy/surge.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -212,11 +212,11 @@ ws_headers = comma "ws-headers" equals headers:$[^,]+ {
212212
const result = {};
213213
pairs.forEach(pair => {
214214
const [key, value] = pair.trim().split(":");
215-
result[key.trim()] = value.trim();
215+
result[key.trim()] = value.trim().trim().replace(/^"(.*?)"$/, '$1').replace(/^'(.*?)'$/, '$1');
216216
})
217217
obfs["ws-headers"] = result;
218218
}
219-
ws_path = comma "ws-path" equals path:uri { obfs.path = path; }
219+
ws_path = comma "ws-path" equals path:uri { obfs.path = path.trim().replace(/^"(.*?)"$/, '$1').replace(/^'(.*?)'$/, '$1'); }
220220
221221
obfs = comma "obfs" equals type:("http"/"tls") { obfs.type = type; }
222222
obfs_host = comma "obfs-host" equals host:domain { obfs.host = host; };

backend/src/core/proxy-utils/parsers/peggy/surge.peg

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -209,11 +209,11 @@ ws_headers = comma "ws-headers" equals headers:$[^,]+ {
209209
const result = {};
210210
pairs.forEach(pair => {
211211
const [key, value] = pair.trim().split(":");
212-
result[key.trim()] = value.trim();
212+
result[key.trim()] = value.trim().replace(/^"(.*?)"$/, '$1').replace(/^'(.*?)'$/, '$1');
213213
})
214214
obfs["ws-headers"] = result;
215215
}
216-
ws_path = comma "ws-path" equals path:uri { obfs.path = path; }
216+
ws_path = comma "ws-path" equals path:uri { obfs.path = path.trim().replace(/^"(.*?)"$/, '$1').replace(/^'(.*?)'$/, '$1'); }
217217

218218
obfs = comma "obfs" equals type:("http"/"tls") { obfs.type = type; }
219219
obfs_host = comma "obfs-host" equals host:domain { obfs.host = host; };

0 commit comments

Comments
 (0)