Decode percent-encoded tags and filter release artifacts

This commit is contained in:
2026-07-08 21:14:00 +03:00
parent f6b722b22a
commit 2e80f7b8eb
8 changed files with 179 additions and 9 deletions

View File

@@ -113,6 +113,58 @@ fn missing_local_singbox_config_defaults_to_optional_empty_state() {
cleanup(&root);
}
#[test]
fn reads_percent_encoded_singbox_tags_as_utf8() {
let root = test_root("local-singbox-percent-tags");
let storage = JsonStorage::new(root.clone());
let encoded_tag =
"%D0%A3%D0%BC%D0%BD%D1%8B%D0%B9%20%F0%9F%87%B3%F0%9F%87%B1-%3E%F0%9F%87%B7%F0%9F%87%BA";
let decoded_tag = "Умный 🇳🇱->🇷🇺";
storage
.write_local_singbox_config(&LocalSingBoxConfig {
selected_server_tag: Some(encoded_tag.to_string()),
..LocalSingBoxConfig::default()
})
.expect("write local sing-box config");
storage
.write_singbox_subscription_cache(&SubscriptionCache {
config: serde_json::json!({
"outbounds": [
{
"type": "vless",
"tag": encoded_tag,
"server": "nl.example.test",
"server_port": 443
}
]
}),
servers: vec![SubscriptionServer {
tag: encoded_tag.to_string(),
server_type: "vless".to_string(),
server: "nl.example.test".to_string(),
server_port: 443,
}],
user_info: serde_json::Map::new(),
fetched_at: "2026-07-07T10:00:00Z".to_string(),
})
.expect("write subscription cache");
let config = storage
.read_local_singbox_config()
.expect("read local sing-box config");
let cache = storage
.read_singbox_subscription_cache()
.expect("read subscription cache")
.expect("subscription cache");
assert_eq!(config.selected_server_tag, Some(decoded_tag.to_string()));
assert_eq!(cache.servers[0].tag, decoded_tag);
assert_eq!(cache.config["outbounds"][0]["tag"], decoded_tag);
cleanup(&root);
}
#[test]
fn invalid_subscription_cache_falls_back_to_none() {
let root = test_root("invalid-subscription-cache");

View File

@@ -44,6 +44,19 @@ fn parses_base64_vless_link_list() {
assert_eq!(outbound["packet_encoding"], "xudp");
}
#[test]
fn decodes_percent_encoded_vless_fragment_tag() {
let link = sample_vless_link(
"%D0%A3%D0%BC%D0%BD%D1%8B%D0%B9%20%F0%9F%87%B3%F0%9F%87%B1-%3E%F0%9F%87%B7%F0%9F%87%BA",
);
let parsed = parse_subscription_body(&link).expect("vless link should parse");
let outbound = &parsed.config["outbounds"][0];
assert_eq!(parsed.servers[0].tag, "Умный 🇳🇱->🇷🇺");
assert_eq!(outbound["tag"], "Умный 🇳🇱->🇷🇺");
}
#[test]
fn rejects_body_without_supported_outbounds() {
let error = parse_subscription_body(r#"{"outbounds":[{"type":"direct","tag":"direct"}]}"#)