Skip to main content

validate_display_name

Function validate_display_name 

Source
pub fn validate_display_name(name: &str) -> Result<(), String>
Expand description

Checks a readable display name (D46).

Looser than validate_username on purpose: this string is never a principal, never a path segment, never an ACL subject and never a channel, so the reasons a username is restricted do not apply to it. What it must not do is break the files and pages that render it, so control characters and newlines are refused and the length is capped.

The one restriction that is not about rendering: a name may not be spelled like a handle. A page shows an unresolvable handle as itself, so a display name of HANDLE_CHARS hex characters renders exactly as somebody else’s deleted account does, and the person it points at cannot correct the record because their name is the thing that was deleted. Refused at the door because the alternative is a rendering rule that has to know which of two identical strings it is holding.

§Errors

Returns a message when it is empty, too long, carries a control character, or is spelled like an account handle.