From e7a9f8f7556fd8d89652aec2271b745563c8b500 Mon Sep 17 00:00:00 2001 From: miewx Date: Thu, 30 Oct 2025 11:24:40 +0800 Subject: [PATCH] add support x-oss-meta-subscription-userinfo (#5234) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * add support x-oss-meta-subscription-userinfo * Update prfitem.rs match any subscription-userinfo * Update prfitem.rs 改为 ends_with 更好 * feat(config): enforce stricter header match for subscription usage --------- Co-authored-by: i18n Co-authored-by: Slinetrac --- src-tauri/src/config/prfitem.rs | 31 ++++++++++++++++++++----------- 1 file changed, 20 insertions(+), 11 deletions(-) diff --git a/src-tauri/src/config/prfitem.rs b/src-tauri/src/config/prfitem.rs index 7475cf1f..46c86478 100644 --- a/src-tauri/src/config/prfitem.rs +++ b/src-tauri/src/config/prfitem.rs @@ -297,18 +297,27 @@ impl PrfItem { let header = resp.headers(); // parse the Subscription UserInfo - let extra = match header.get("Subscription-Userinfo") { - Some(value) => { - let sub_info = value.to_str().unwrap_or(""); - Some(PrfExtra { - upload: help::parse_str(sub_info, "upload").unwrap_or(0), - download: help::parse_str(sub_info, "download").unwrap_or(0), - total: help::parse_str(sub_info, "total").unwrap_or(0), - expire: help::parse_str(sub_info, "expire").unwrap_or(0), - }) + let extra; + 'extra: { + for (k, v) in header.iter() { + let key_lower = k.as_str().to_ascii_lowercase(); + // Accept standard custom-metadata prefixes (x-amz-meta-, x-obs-meta-, x-cos-meta-, etc.). + if key_lower + .strip_suffix("subscription-userinfo") + .is_some_and(|prefix| prefix.is_empty() || prefix.ends_with('-')) + { + let sub_info = v.to_str().unwrap_or(""); + extra = Some(PrfExtra { + upload: help::parse_str(sub_info, "upload").unwrap_or(0), + download: help::parse_str(sub_info, "download").unwrap_or(0), + total: help::parse_str(sub_info, "total").unwrap_or(0), + expire: help::parse_str(sub_info, "expire").unwrap_or(0), + }); + break 'extra; + } } - None => None, - }; + extra = None; + } // parse the Content-Disposition let filename = match header.get("Content-Disposition") {