forked from jmug/stoatchat
feat: restrict role colours to regex (increase length limit)
This commit is contained in:
@@ -3,6 +3,7 @@ pub mod manipulation;
|
||||
pub mod pfp;
|
||||
pub mod rauth;
|
||||
pub mod r#ref;
|
||||
pub mod regex;
|
||||
pub mod result;
|
||||
pub mod value;
|
||||
pub mod variables;
|
||||
|
||||
18
crates/quark/src/util/regex.rs
Normal file
18
crates/quark/src/util/regex.rs
Normal file
@@ -0,0 +1,18 @@
|
||||
use once_cell::sync::Lazy;
|
||||
use regex::Regex;
|
||||
|
||||
/// Regex for valid role colours
|
||||
///
|
||||
/// Allows the use of named colours, rgb(a), variables and all gradients.
|
||||
///
|
||||
/// Source:
|
||||
/// ```regex
|
||||
/// VALUE = [a-z ]+|var\(--[a-z\d-]+\)|rgba?\([\d, ]+\)|#[a-f0-9]+
|
||||
/// ADDITIONAL_VALUE = \d+deg
|
||||
/// STOP = ([ ]+(\d{1,3}%|0))?
|
||||
///
|
||||
/// ^(?:VALUE|(repeating-)?(linear|conic|radial)-gradient\((VALUE|ADDITIONAL_VALUE)STOP(,[ ]*(VALUE)STOP)+\))$
|
||||
/// ```
|
||||
pub static RE_COLOUR: Lazy<Regex> = Lazy::new(|| {
|
||||
Regex::new(r"^(?:[a-z ]+|var\(--[a-z\d-]+\)|rgba?\([\d, ]+\)|#[a-f0-9]+|(repeating-)?(linear|conic|radial)-gradient\(([a-z ]+|var\(--[a-z\d-]+\)|rgba?\([\d, ]+\)|#[a-f0-9]+|\d+deg)([ ]+(\d{1,3}%|0))?(,[ ]*([a-z ]+|var\(--[a-z\d-]+\)|rgba?\([\d, ]+\)|#[a-f0-9]+)([ ]+(\d{1,3}%|0))?)+\))$").unwrap()
|
||||
});
|
||||
Reference in New Issue
Block a user