fix(sdk): add more invalid characters for room aliases

This commit is contained in:
Jorge Martín
2024-11-08 10:24:12 +01:00
committed by Jorge Martin Espinosa
parent 7c600fddf0
commit 46232ee2c1
2 changed files with 4 additions and 4 deletions

View File

@@ -66,7 +66,7 @@ pub enum RoomDisplayName {
}
const WHITESPACE_REGEX: &str = r"\s+";
const INVALID_SYMBOLS_REGEX: &str = r"[#,:]+";
const INVALID_SYMBOLS_REGEX: &str = r"[#,:\{\}\\]+";
impl RoomDisplayName {
/// Transforms the current display name into the name part of a
@@ -636,7 +636,7 @@ mod tests {
fn test_room_alias_from_room_display_name_removes_invalid_ascii_symbols() {
assert_eq!(
"roomalias",
RoomDisplayName::Named("#Room,Alias:".to_owned()).to_room_alias_name()
RoomDisplayName::Named("#Room,{Alias}:".to_owned()).to_room_alias_name()
);
}
}

View File

@@ -191,7 +191,7 @@ impl IntoRawStateEventContent for &Box<RawJsonValue> {
}
}
const INVALID_ROOM_ALIAS_NAME_CHARS: &str = "#,:";
const INVALID_ROOM_ALIAS_NAME_CHARS: &str = "#,:{}\\";
/// Verifies the passed `String` matches the expected room alias format:
///
@@ -265,7 +265,7 @@ mod test {
#[test]
fn test_is_room_alias_format_valid_when_name_part_has_invalid_char_is_not_valid() {
assert!(!is_room_alias_format_valid("#alias,test:domain.org".to_owned()))
assert!(!is_room_alias_format_valid("#a#lias,{t\\est}:domain.org".to_owned()))
}
#[test]