fix(sub): bound what a remote routing profile renders to

Remote routing sources are fetched documents the panel re-renders on
every subscription request. A Clash YAML document stays small through
aliases, which decode to one shared value but are written out in full,
so it now has to fit a 4 MiB written-size budget and 16 levels of
nesting when it is accepted (and when a persisted copy is loaded). A JSON
routing profile could repeat route groups, each copy repeating every
site list; a group now counts once, since a repeat can never match.
This commit is contained in:
MHSanaei
2026-10-31 08:59:23 +00:00
parent 8359a0f72e
commit 661a169045
4 changed files with 91 additions and 1 deletions
+12
View File
@@ -94,6 +94,18 @@ func TestParseJsonRoutingSpecRouteOrderUnknownSegments(t *testing.T) {
}
}
// Every group copy repeats the profile's whole site lists in the rendered routing, and a
// later copy can never match, so a remote profile repeating groups must not multiply them.
func TestParseJsonRoutingSpecRouteOrderKeepsEachGroupOnce(t *testing.T) {
spec, _, err := parseJsonRoutingSpec(`{"RouteOrder":"` + strings.Repeat("proxy-direct-block-", 500) + `proxy"}`)
if err != nil {
t.Fatalf("parse: %v", err)
}
if strings.Join(spec.RouteOrder, ",") != "proxy,direct,block" {
t.Fatalf("RouteOrder = %d segments, want proxy,direct,block once each", len(spec.RouteOrder))
}
}
func TestParseJsonRoutingSpecDeeplinks(t *testing.T) {
payload := mustMarshal(t, fullRoutingPayload())
cases := []string{