identifiers-validation: Allow +
in the localpart of user IDs
According to MSC4009
This commit is contained in:
parent
a9a6e67ed0
commit
8bdfd809e4
@ -1,9 +1,15 @@
|
|||||||
# [unreleased]
|
# [unreleased]
|
||||||
|
|
||||||
|
Bug fixes:
|
||||||
|
|
||||||
- Don't consider empty localpart of a user ID as valid
|
- Don't consider empty localpart of a user ID as valid
|
||||||
- It is accepted under the `compat-user-id` feature, but not considered
|
- It is accepted under the `compat-user-id` feature, but not considered
|
||||||
fully-conforming
|
fully-conforming
|
||||||
|
|
||||||
|
Improvements:
|
||||||
|
|
||||||
|
- Allow `+` in the localpart of user IDs according to MSC4009
|
||||||
|
|
||||||
# 0.9.1
|
# 0.9.1
|
||||||
|
|
||||||
Improvements:
|
Improvements:
|
||||||
|
@ -20,9 +20,9 @@ pub fn validate(s: &str) -> Result<(), Error> {
|
|||||||
pub fn localpart_is_fully_conforming(localpart: &str) -> Result<bool, Error> {
|
pub fn localpart_is_fully_conforming(localpart: &str) -> Result<bool, Error> {
|
||||||
// See https://spec.matrix.org/latest/appendices/#user-identifiers
|
// See https://spec.matrix.org/latest/appendices/#user-identifiers
|
||||||
let is_fully_conforming = !localpart.is_empty()
|
let is_fully_conforming = !localpart.is_empty()
|
||||||
&& localpart
|
&& localpart.bytes().all(
|
||||||
.bytes()
|
|b| matches!(b, b'0'..=b'9' | b'a'..=b'z' | b'-' | b'.' | b'=' | b'_' | b'/' | b'+'),
|
||||||
.all(|b| matches!(b, b'0'..=b'9' | b'a'..=b'z' | b'-' | b'.' | b'=' | b'_' | b'/'));
|
);
|
||||||
|
|
||||||
if !is_fully_conforming {
|
if !is_fully_conforming {
|
||||||
// If it's not fully conforming, check if it contains characters that are also disallowed
|
// If it's not fully conforming, check if it contains characters that are also disallowed
|
||||||
|
Loading…
x
Reference in New Issue
Block a user