diff options
author | Quentin Dufour <quentin@deuxfleurs.fr> | 2022-05-04 09:14:39 +0200 |
---|---|---|
committer | Quentin Dufour <quentin@deuxfleurs.fr> | 2022-05-04 09:14:39 +0200 |
commit | 6383d9877282b98fa058ea4101ca6a8578c7514e (patch) | |
tree | 27b7127c27a7a60ce415a30484a1ea3e4f651dde | |
parent | 625fd241131d758aa4d2ccd2f71fcaf1d44d574a (diff) | |
download | tricot-6383d9877282b98fa058ea4101ca6a8578c7514e.tar.gz tricot-6383d9877282b98fa058ea4101ca6a8578c7514e.zip |
Support headers with spaces in their valuedocker-37
-rw-r--r-- | src/proxy_config.rs | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/src/proxy_config.rs b/src/proxy_config.rs index e380885..bf7ae32 100644 --- a/src/proxy_config.rs +++ b/src/proxy_config.rs @@ -161,7 +161,7 @@ fn parse_tricot_tag( } fn parse_tricot_add_header_tag(tag: &str) -> Option<(String, String)> { - let splits = tag.split(' ').collect::<Vec<_>>(); + let splits = tag.splitn(3, ' ').collect::<Vec<_>>(); if splits.len() == 3 && splits[0] == "tricot-add-header" { Some((splits[1].to_string(), splits[2].to_string())) } else { @@ -352,3 +352,19 @@ pub fn spawn_proxy_config_task( rx } + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn test_parse_tricot_add_header_tag() { + match parse_tricot_add_header_tag("tricot-add-header Content-Security-Policy default-src 'none'; img-src 'self'; script-src 'self'; style-src 'self'") { + Some((name, value)) => { + assert_eq!(name, "Content-Security-Policy"); + assert_eq!(value, "default-src 'none'; img-src 'self'; script-src 'self'; style-src 'self'"); + } + _ => panic!("Passed a valid tag but the function says it is not valid") + } + } +} |