fix: normalize literal \n separators in ParseProxyLines

Some frontends stuff multi-line subscription content into a single
string with literal backslash-n sequences. The whole blob parsed as
one URI whose fragment swallowed the remaining links (1 node with a
garbage name instead of N nodes).

Normalize literal \r\n / \n to real newlines at the ParseProxyLines
entry, after format detection and before splitting. Real newline
input and single links are unaffected.

HH-766
This commit is contained in:
杨豪
2026-08-28 21:05:34 +08:00
parent 4c5f5e9720
commit 139dd50763
2 changed files with 82 additions and 0 deletions
+8
View File
@@ -127,7 +127,15 @@ func ParseYamlProxies(raw string) []model.ProxyNode {
// ParseProxyLines splits raw text into lines, skips comments/blanks/section headers,
// and parses each line as a URI or client config line.
//
// Literal "\n" / "\r\n" sequences (backslash + n, as produced by some frontends
// stuffing multi-line content into a single string) are normalized to real
// newlines before splitting so each link is parsed as its own line.
func ParseProxyLines(raw string) []model.ProxyNode {
if strings.Contains(raw, `\n`) {
raw = strings.ReplaceAll(raw, `\r\n`, "\n")
raw = strings.ReplaceAll(raw, `\n`, "\n")
}
lines := strings.Split(raw, "\n")
var result []model.ProxyNode
index := 0