From 890b4e05d2720c01334ff18b698146e4903b3538 Mon Sep 17 00:00:00 2001 From: Yiffy Dev Date: Wed, 30 Oct 2024 16:41:45 +0500 Subject: [PATCH] ensure generated hash is safe --- examples/use-styles/src/main.rs | 4 ++-- sabry_intrnl/src/scoper/hash.rs | 3 ++- sabry_procmacro_impl/src/impls/styly.rs | 3 +-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/examples/use-styles/src/main.rs b/examples/use-styles/src/main.rs index 6cdf59d..6472b0e 100644 --- a/examples/use-styles/src/main.rs +++ b/examples/use-styles/src/main.rs @@ -5,7 +5,7 @@ styly!(pub const bundlemod { .someth { @include tokens.clickable; background-color: black; - &-dark { + &__dark { background-color: white; } } @@ -16,6 +16,6 @@ styly!(pub const filemod:sass "src/main.sass"); fn main(){ println!("someth class codemod styles: {}", bundlemod::someth); println!("someth class filemod styles: {}", filemod::someth); - println!("someth-dark selector will be: {}", bundlemod::_dark(bundlemod::someth)); + //println!("someth-dark selector will be: {}", bundlemod::_dark(bundlemod::someth)); println!("Thats how we used the styles! Good luck!!"); } diff --git a/sabry_intrnl/src/scoper/hash.rs b/sabry_intrnl/src/scoper/hash.rs index 9f8a9e4..4188a39 100644 --- a/sabry_intrnl/src/scoper/hash.rs +++ b/sabry_intrnl/src/scoper/hash.rs @@ -2,7 +2,7 @@ use base64::Engine; use crate::config::SabryHashConfig; -use super::ArbitraryScope; +use super::{apply_basic_rusty_member_gen_rules, ArbitraryScope}; /// Convenience wrapper for String-being-a-hash #[derive(Debug, Clone, PartialEq, Eq, Hash)] @@ -50,6 +50,7 @@ impl ScopeHash { //? This isn't right. "size" is size of hash in symbols. // naaah, its fine :D (Dan) let hash = base64::prelude::BASE64_URL_SAFE_NO_PAD.encode(&hash[..size]); + let hash = apply_basic_rusty_member_gen_rules(&hash); Self(hash) } diff --git a/sabry_procmacro_impl/src/impls/styly.rs b/sabry_procmacro_impl/src/impls/styly.rs index 56a977c..4a157d2 100644 --- a/sabry_procmacro_impl/src/impls/styly.rs +++ b/sabry_procmacro_impl/src/impls/styly.rs @@ -85,8 +85,7 @@ pub fn styly_macro_impl(input: TokenStream) -> TokenStream { let interp = s .as_sass_interpolated() .and_then(|i| i.elements.first()) - .and_then(|e| e.as_static()) - .and_then(|s| Some(s.raw.to_string())); + .and_then(|e| e.as_static().map(|s| s.raw.to_string())); interp })