additional character check on room alias
Signed-off-by: strawberry <strawberry@puppygock.gay>
This commit is contained in:
parent
e272f0f34f
commit
8754f0e2a5
1 changed files with 8 additions and 0 deletions
|
@ -109,6 +109,8 @@ pub async fn create_room_route(
|
||||||
body.room_alias_name
|
body.room_alias_name
|
||||||
.as_ref()
|
.as_ref()
|
||||||
.map_or(Ok(None), |localpart| {
|
.map_or(Ok(None), |localpart| {
|
||||||
|
|
||||||
|
// Basic checks on the room alias validity
|
||||||
if localpart.contains(':') {
|
if localpart.contains(':') {
|
||||||
return Err(Error::BadRequest(
|
return Err(Error::BadRequest(
|
||||||
ErrorKind::InvalidParam,
|
ErrorKind::InvalidParam,
|
||||||
|
@ -129,7 +131,13 @@ pub async fn create_room_route(
|
||||||
ErrorKind::InvalidParam,
|
ErrorKind::InvalidParam,
|
||||||
"Room alias is excessively long, clients may not be able to handle this. Please shorten it.",
|
"Room alias is excessively long, clients may not be able to handle this. Please shorten it.",
|
||||||
));
|
));
|
||||||
|
} else if localpart.contains('"') {
|
||||||
|
return Err(Error::BadRequest(
|
||||||
|
ErrorKind::InvalidParam,
|
||||||
|
"Room alias contained `\"` which is not allowed.",
|
||||||
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
let alias = RoomAliasId::parse(format!(
|
let alias = RoomAliasId::parse(format!(
|
||||||
"#{}:{}",
|
"#{}:{}",
|
||||||
localpart,
|
localpart,
|
||||||
|
|
Loading…
Add table
Reference in a new issue