Afbase/aturi validation rsky syntax#39
Conversation
…eric string input parameter in rsky-syntax
…dea as parse and parse_relative are reference only in this file
…alidation methods
| expect_valid("at://did:plc:asdf123/com.atproto.feed.post/asdf123"); | ||
| expect_valid("at://did:plc:asdf123/com.atproto.feed.post/a"); | ||
| expect_valid("at://did:plc:asdf123/com.atproto.feed.post/%23"); | ||
| expect_valid("at://did:plc:asdf123/com.atproto.feed.post/$@!*)(:,;~.sdf123"); |
There was a problem hiding this comment.
Some of these don't look like valid record keys to me. Per the docs:
Regardless of the type, Record Keys must fulfill some baseline syntax constraints:
- restricted to a subset of ASCII characters — the allowed characters are alphanumeric (A-Za-z0-9), period, dash, underscore, colon, or tilde (.-_:~)
dollar signs, at signs, parentheses, semi-colons, asterisks, and exclamation points shouldn't be allowed.
There was a problem hiding this comment.
would you like me conform more closely to the docs or to what typescript has?
Typescript's validation is much more relaxed at this time 😞
rsky-syntax/src/aturi_validation.rs
Outdated
| expect_valid("at://did:plc:asdf123/com.atproto.feed.post/record"); | ||
| expect_valid(&format!( | ||
| "at://did:plc:asdf123/com.atproto.feed.post/{}", | ||
| "o".repeat(800) |
There was a problem hiding this comment.
must have at least 1 and at most 512 characters per the docs
|
@rudyfraser - give me a another day or so to work on this. There are some discrepancies between the typescript and atproto specifications.
I'll let you know when it's ready for review again |
Sounds good. Just to answer your other comment the atproto specs should be the source of truth where there are differences between the spec and the TS code. I imagine discrepancies should be rare (since it's the same org working on both, lol) but for a case like this it'd be the spec. I'll keep an eye out for your next comment to review. |
Okay so here's what I think is going on reviewing the typescript code and specification more thoroughly:
|
|
An idea: We could create a validation function that is more strict and conform to the specification. This would got beyond the reference implementation in Typescript. |
|
For now could you open an issue for the more strict version? Since this conforms to the canonical one I think we're good to go here. |
Closes #38
Okay upon further testing and review, the ensureValidAtUri in the typscript codebase does not consider:
AtUri::newcode.You'll still be able to:
and similarly in the other validation functions implementations,
ensure_valid_datetime, if ok, will return aDateTime<FixedOffset>>. So you'll be able to:I'm doing so since the code parses the string to a datetime object successfully. The other validation code evaluates strings and it's a bit redundant to return a string again.