-
Notifications
You must be signed in to change notification settings - Fork 207
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* chore: address linter issues Perform changes suggested by linter; no functional changes. * error.go: make ErrInvalidID a const Make ErrInvalidID a constant instead of a variable. This prevent it from being changed by external packages; a behavior that although allowed by the compiler, should probably be considered an invalid operation. * add benchmark and new failing test for FromString * fix: let decode look for additional base32 padding Update FromString and XID.TextUnmarshal so that it looks for discarded bits in the final source character. This ensures that XIDs that have been manually tampered with in a way that's ignored by base32 decode, will not pass as valid.
- Loading branch information
Showing
3 changed files
with
86 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package xid | ||
|
||
const ( | ||
// ErrInvalidID is returned when trying to unmarshal an invalid ID. | ||
ErrInvalidID strErr = "xid: invalid ID" | ||
) | ||
|
||
// strErr allows declaring errors as constants. | ||
type strErr string | ||
|
||
func (err strErr) Error() string { return string(err) } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters