Allow emoji names containing hyphens

This commit is contained in:
silverpill 2023-03-25 10:12:55 +00:00
parent 73b576c643
commit 441850dd21
2 changed files with 9 additions and 1 deletions

View file

@ -10,6 +10,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
- Added `prune-remote-emojis` command.
### Changed
- Allow emoji names containing hyphens.
### Fixed
- Fixed error in emoji update SQL query.

View file

@ -2,7 +2,7 @@ use regex::Regex;
use crate::errors::ValidationError;
const EMOJI_NAME_RE: &str = r"^[\w.]+$";
const EMOJI_NAME_RE: &str = r"^[a-zA-Z0-9._-]+$";
pub const EMOJI_MAX_SIZE: usize = 250 * 1000; // 250 kB
pub const EMOJI_LOCAL_MAX_SIZE: usize = 50 * 1000; // 50 kB
pub const EMOJI_MEDIA_TYPES: [&str; 3] = [
@ -29,6 +29,10 @@ mod tests {
let result = validate_emoji_name(valid_name);
assert!(result.is_ok());
let valid_name = "01-emoji-name";
let result = validate_emoji_name(valid_name);
assert!(result.is_ok());
let invalid_name = "emoji\"<script>";
let result = validate_emoji_name(invalid_name);
assert!(result.is_err());