Skip to content

Commit

Permalink
fix(sdk): add more invalid characters for room aliases
Browse files Browse the repository at this point in the history
  • Loading branch information
jmartinesp committed Nov 8, 2024
1 parent 7c600fd commit 46232ee
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions crates/matrix-sdk-base/src/rooms/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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()
);
}
}
4 changes: 2 additions & 2 deletions crates/matrix-sdk/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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:
///
Expand Down Expand Up @@ -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]
Expand Down

0 comments on commit 46232ee

Please sign in to comment.