Skip to content

Commit fa61b8b

Browse files
Sujay JayakarConvex, Inc.
authored andcommitted
Add DB verifier check to see if we have any noncanonical IDs (#24645)
GitOrigin-RevId: f2d13c9e7f5594be16e172651941429ba31a3653
1 parent 758e9bd commit fa61b8b

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

crates/value/src/id_v6.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,14 @@ impl DocumentIdV6 {
8383
base32::encode(&buf[..pos])
8484
}
8585

86+
/// Is the given string an ID that's not in its canonical encoding?
87+
pub fn is_noncanonical_id(s: &str) -> bool {
88+
let Ok(id) = Self::decode(s) else {
89+
return false;
90+
};
91+
s != id.encode()
92+
}
93+
8694
pub fn decode(s: &str) -> Result<Self, IdDecodeError> {
8795
// NB: We want error paths to be as quick as possible, even if `s` is very long.
8896
// So, be sure to do the length check before decoding the base32.

0 commit comments

Comments
 (0)