Skip to content

Commit 46232ee

Browse files
committed
fix(sdk): add more invalid characters for room aliases
1 parent 7c600fd commit 46232ee

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

crates/matrix-sdk-base/src/rooms/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ pub enum RoomDisplayName {
6666
}
6767

6868
const WHITESPACE_REGEX: &str = r"\s+";
69-
const INVALID_SYMBOLS_REGEX: &str = r"[#,:]+";
69+
const INVALID_SYMBOLS_REGEX: &str = r"[#,:\{\}\\]+";
7070

7171
impl RoomDisplayName {
7272
/// Transforms the current display name into the name part of a
@@ -636,7 +636,7 @@ mod tests {
636636
fn test_room_alias_from_room_display_name_removes_invalid_ascii_symbols() {
637637
assert_eq!(
638638
"roomalias",
639-
RoomDisplayName::Named("#Room,Alias:".to_owned()).to_room_alias_name()
639+
RoomDisplayName::Named("#Room,{Alias}:".to_owned()).to_room_alias_name()
640640
);
641641
}
642642
}

crates/matrix-sdk/src/utils.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ impl IntoRawStateEventContent for &Box<RawJsonValue> {
191191
}
192192
}
193193

194-
const INVALID_ROOM_ALIAS_NAME_CHARS: &str = "#,:";
194+
const INVALID_ROOM_ALIAS_NAME_CHARS: &str = "#,:{}\\";
195195

196196
/// Verifies the passed `String` matches the expected room alias format:
197197
///
@@ -265,7 +265,7 @@ mod test {
265265

266266
#[test]
267267
fn test_is_room_alias_format_valid_when_name_part_has_invalid_char_is_not_valid() {
268-
assert!(!is_room_alias_format_valid("#alias,test:domain.org".to_owned()))
268+
assert!(!is_room_alias_format_valid("#a#lias,{t\\est}:domain.org".to_owned()))
269269
}
270270

271271
#[test]

0 commit comments

Comments
 (0)