From c5db6d56ad4dce13e3926def27d14b787af01ab5 Mon Sep 17 00:00:00 2001 From: Jonas Platte Date: Tue, 23 Jun 2020 12:40:01 +0200 Subject: [PATCH] Remove RoomVersionId::custom constructor It could be used to create invalid room versions like an empty one or one with more than 32 code points. --- ruma-identifiers/CHANGELOG.md | 5 ++++- ruma-identifiers/src/room_version_id.rs | 9 --------- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/ruma-identifiers/CHANGELOG.md b/ruma-identifiers/CHANGELOG.md index 790468ca..85890ffb 100644 --- a/ruma-identifiers/CHANGELOG.md +++ b/ruma-identifiers/CHANGELOG.md @@ -2,7 +2,10 @@ Breaking changes: -* Removed diesel integration. If you were using it, please comment on the corresponding issue: +* Remove `RoomVersionId::custom`. It could be used to create invalid room versions (empty or + exceeding 32 code points in length). Use the `TryFrom<&str>` or `TryFrom` implementation + instead. +* Remove diesel integration. If you were using it, please comment on the corresponding issue: https://github.com/ruma/ruma-identifiers/issues/22 * Remove `TryFrom>` implementations for identifier types * Update `parse_with_server_name`s signature (instead of `Into` it now requires diff --git a/ruma-identifiers/src/room_version_id.rs b/ruma-identifiers/src/room_version_id.rs index 776a5028..cdd2ef69 100644 --- a/ruma-identifiers/src/room_version_id.rs +++ b/ruma-identifiers/src/room_version_id.rs @@ -87,14 +87,6 @@ impl RoomVersionId { Self(InnerRoomVersionId::Version6) } - /// Creates a custom room version ID from the given string slice. - pub fn custom(id: String) -> Self - where - String: Into, - { - Self(InnerRoomVersionId::Custom(id.into())) - } - /// Whether or not this room version is an official one specified by the Matrix protocol. pub fn is_official(&self) -> bool { !self.is_custom() @@ -408,7 +400,6 @@ mod tests { assert!(RoomVersionId::version_3().is_version_3()); assert!(RoomVersionId::version_4().is_version_4()); assert!(RoomVersionId::version_5().is_version_5()); - assert!(RoomVersionId::custom("foo".into()).is_custom()); } #[test]