Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Duniter v2S
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Monitor
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
nodes
rust
Duniter v2S
Merge requests
!119
restrict identity name
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
restrict identity name
hugo-comment
into
master
Overview
1
Commits
3
Pipelines
4
Changes
1
Merged
Hugo Trentesaux
requested to merge
hugo-comment
into
master
2 years ago
Overview
1
Commits
3
Pipelines
4
Changes
1
Expand
see discussion
https://forum.duniter.org/t/format-du-userid/10147
0
0
Merge request reports
Viewing commit
b1ca24ce
Show latest version
1 file
+
9
−
4
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
b1ca24ce
improve comments valid identity name
· b1ca24ce
Hugo Trentesaux
authored
2 years ago
primitives/duniter/src/lib.rs
+
9
−
4
Options
@@ -16,15 +16,20 @@
#![cfg_attr(not(feature
=
"std"
),
no_std)]
/// Bound length; forbid trailing or double spaces; accept only ascii alphanumeric or punctuation or space
/// Rules for valid identity names are defined below
/// - Bound length to 64
/// - forbid trailing or double spaces
/// - accept only ascii alphanumeric or punctuation or space
pub
fn
validate_idty_name
(
idty_name
:
&
[
u8
])
->
bool
{
idty_name
.len
()
>=
3
&&
idty_name
.len
()
<=
64
&&
idty_name
[
0
]
!=
32
&&
idty_name
[
idty_name
.len
()
-
1
]
!=
32
&&
idty_name
.len
()
<=
64
// length smaller than 64
&&
idty_name
[
0
]
!=
32
// does not start with space
&&
idty_name
[
idty_name
.len
()
-
1
]
!=
32
// does not end with space
// all characters are alphanumeric or punctuation or space
&&
idty_name
.iter
()
.all
(|
c
|
c
.is_ascii_alphanumeric
()
||
c
.is_ascii_punctuation
()
||
*
c
==
32
)
// disallow two consecutive spaces
&&
idty_name
.iter
()
.zip
(
idty_name
.iter
()
.skip
(
1
))
Loading