:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
fix(ai-research): stop anonymizer panics on colons in custom properties (#106156)
Robbie7198d2b32a83
diff --git a/rust/Cargo.lock b/rust/Cargo.lockindex c04ed6805b05..93a08ceeefec 100644--- a/rust/Cargo.lock+++ b/rust/Cargo.lock@@ -9392,7 +9392,7 @@ dependencies = [[[package]]name = "posthog-replay-anonymizer"-version = "0.7.2"+version = "0.7.3"dependencies = ["ahash 0.8.12","anyhow",diff --git a/rust/replay-anonymizer/Cargo.toml b/rust/replay-anonymizer/Cargo.tomlindex 044f75fde08f..8d69b3b21090 100644--- a/rust/replay-anonymizer/Cargo.toml+++ b/rust/replay-anonymizer/Cargo.toml@@ -1,6 +1,6 @@[package]name = "posthog-replay-anonymizer"-version = "0.7.2"+version = "0.7.3"edition = "2021"description = "PII scrubber for rrweb session-replay events: text/URL redaction, native image blur, and canvas/cv neutralization"license = "MIT"diff --git a/rust/replay-anonymizer/src/css.rs b/rust/replay-anonymizer/src/css.rsindex cdf0a2180f6f..55a4ef4adf0c 100644--- a/rust/replay-anonymizer/src/css.rs+++ b/rust/replay-anonymizer/src/css.rs@@ -206,7 +206,13 @@ fn declaration_value_ranges(css: &str, context: CssContext<'_>) -> Vec<Declaratib';' if paren_depth == 0 && bracket_depth == 0 => {segment_start = position + 1;}- b':' if paren_depth == 0 && bracket_depth == 0 => {+ // A colon in a custom property value, as in `--link: https://…` or a nested block, is not a new declaration.+ b':' if paren_depth == 0+ && bracket_depth == 0+ && ranges+ .last()+ .is_none_or(|previous: &DeclarationRange| position >= previous.end) =>+ {if let Some((property, collect_remote_urls)) =css_property(css[segment_start..position].trim()){@@ -691,6 +697,27 @@ mod tests {assert!(!rewritten.css.contains(&original));}+ #[test]+ fn colons_and_blocks_inside_a_custom_property_value_do_not_start_a_declaration() {+ let allow = AllowLists::default();+ let ctx = Ctx::new(&allow);+ let original = png_data_uri(8, 8, [10, 20, 30, 255]);+ for (css, kept) in [+ (+ format!(":root{{--link:https://example.com/a;--hero:url('{original}')}}"),+ ":root{--link:https://example.com/a;--hero:",+ ),+ (+ format!(":root{{--block:{{--nested:url('{original}')}}}}"),+ ":root{--block:{--nested:",+ ),+ ] {+ let rewritten = rewrite(&ctx, &css, CssContext::Stylesheet).expect("image changes");+ assert!(rewritten.css.starts_with(kept), "{}", rewritten.css);+ assert!(!rewritten.css.contains(&original));+ }+ }+#[test]fn repeated_unterminated_urls_do_not_rescan_the_suffix() {let allow = AllowLists::default();