-
Notifications
You must be signed in to change notification settings - Fork 411
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add label validation for non printable chars #1650
Conversation
Codecov Report
@@ Coverage Diff @@
## main #1650 +/- ##
==========================================
+ Coverage 56.56% 56.62% +0.05%
==========================================
Files 62 62
Lines 8194 8200 +6
==========================================
+ Hits 4635 4643 +8
+ Misses 3121 3120 -1
+ Partials 438 437 -1
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice start. Please see my comment on the test
x/wasm/types/validation.go
Outdated
return !unicode.IsGraphic(r) | ||
}) | ||
if label != labelWithoutNonPrintableChars { | ||
return ErrInvalid.Wrap("label must not have non printable characters") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: let's avoid double negative ;-)
return ErrInvalid.Wrap("label must not have non printable characters") | |
return ErrInvalid.Wrap("label must have printable characters only") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good work! 🏌️
@@ -45,6 +46,15 @@ func ValidateLabel(label string) error { | |||
if label != strings.TrimSpace(label) { | |||
return ErrInvalid.Wrap("label must not start/end with whitespaces") | |||
} | |||
labelWithPrintableCharsOnly := strings.Map(func(r rune) rune { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
very nice use of strings.Map 👍
* Add label validation for non printable chars * Fix printable chars check (cherry picked from commit 1a22c29)
* Add label validation for non printable chars * Fix printable chars check (cherry picked from commit 1a22c29)
* Add label validation for non printable chars * Fix printable chars check (cherry picked from commit 1a22c29) Co-authored-by: pinosu <[email protected]>
Resolves #1623