summaryrefslogtreecommitdiff
path: root/crates/tor-netdoc/src/parse
Commit message (Collapse)AuthorAgeFilesLines
* tor-netdoc: Expose MaybeItem::pos pub(crate)Ian Jackson2026-06-111-1/+1
|
* everywhere: Add #[allow(clippy::string_slice)]Clara Engler2026-06-091-0/+5
| | | | | | | | This commit adds #[allow(clippy::string_slice)] to all functions in the code where string slices are used, alongside a TODO comment. We do this add the function header to have it consistent, as things like expression based allow's are still experimental.
* maint: Run maint/add_warning to deny string slicesClara Engler2026-06-092-0/+2
| | | | | | | | | | | | This commit executes maint/add_warning with the just added change to deny string slices except in tests. I recommend auditing this by checking out the previous commit followed by running the script yourself and then verifying that the diff is identical to this commit. This commit makes cargo clippy fail. We will add exceptions in the next commit.
* tor-netdoc: Un-gate "routerdesc" cargo featureIan Jackson2026-04-281-2/+0
| | | | As per #2492.
* tor-netdoc: Un-gate BASE64_PEM_MAX_LINEIan Jackson2026-04-231-1/+0
|
* tor-netdoc: Add a blank line for reading clarityIan Jackson2025-11-181-0/+1
| | | | | As per https://gitlab.torproject.org/tpo/core/arti/-/merge_requests/3471#note_3288716
* tor-netdoc: Split off Keyword::to_str into its own trait (fmt)Ian Jackson2025-11-181-1/+3
|
* tor-netdoc: Split off Keyword::to_str into its own traitIan Jackson2025-11-182-6/+5
| | | | | My planned encoding derive macro is not going to use `decl_keyword!` but will need to call `NetdocEncoder::item`.
* tor-netdoc: Split off Keyword::to_str - prep code motionIan Jackson2025-11-181-8/+8
|
* tor-netdoc: Keyword: Say that to_str is the actual document keywordIan Jackson2025-11-181-2/+3
| | | | | | | | | NetdocEncoder::item uses it this way. Presumably it is right at least in those cases where this method is called. The only implementor of this trait right now is the output from `decl_keyword!` in the old parser, which is (generally) expected to be the actual keyword.
* tor-netdoc: Introduce "encode" feature for the like-named moduleIan Jackson2025-11-101-1/+1
| | | | | | | We're going to introduce facilities for encoding more generally, and we'll want a way to enable them. Instead, have a separate feature for *encoding* documents.
* Fix name of clippy lint to unchecked_time_subtraction (2)Ian Jackson2025-11-062-2/+2
| | | | Run maint/add_warning
* tor-netdoc: Abolish ParseRouterStatus and make several things not pubIan Jackson2025-08-263-7/+5
| | | | | | | The methods in ParseRouterStatus can now be inherent. This starts a cascade of unused stuff, and stuff which doesn't need to be pub any more.
* tor-netdoc: Expose base64_decode_multiline to crateIan Jackson2025-08-141-1/+1
| | | | The new parser is going to reuse this.
* Switch Cargo.toml files to edition 2024.Nick Mathewson2025-08-071-5/+1
| | | | | | | | | | | | | | First, run ``` git grep -l "^edition =" | xargs perl -i -pe 's/^edition *=.*/edition = "2024"/;' ``` Second, manually verify that all Cargo.toml files have changed, and nothing else has changed. Third, run cargo fmt again.
* Update code for Edition 2024Nick Mathewson2025-08-071-2/+6
| | | | | | | | | | | | | | | | | | 1. Run cargo fix --edition 2. Selectively revert the "if let"->"match" changes. These changes are meant to protect us from the lifetime changes for "if let" bindings in Rust 2024. But we're not actually relying on the old lifetime rules anywhere, and the match syntax here is quite ugly. 3. Automatically revert `$pat:expr_2021` to `$pat:expr`. (We don't actually want to restrict the expression syntax that our macros accept). Done with `git grep -l expr_2021 | xargs perl -i -pe 's/expr_2021/expr/g;'` 4. Run cargo fmt.
* netdoc: disallow extraneous space within final signature itemNick Mathewson2025-07-101-0/+9
| | | | Part of proposal 360.
* netdoc: Fix Item::end_pos() behavior, and add tests.Nick Mathewson2025-07-101-6/+30
| | | | | Previously it didn't include end-of-line space, even though the docs said it did.
* Add test to enforce parser behavior wrt start-of-line space.Nick Mathewson2025-07-101-0/+46
|
* tor-netdoc: Removed dependency on `once_cell`hashcatHitman2025-06-142-4/+4
| | | | | | - Replaced `once_cell::sync::Lazy` with `std::sync::LazyLock`. Signed-off-by: hashcatHitman <[email protected]>
* tor-netdoc: use more idiomatic rustSteven Engler2025-04-031-2/+1
|
* tor-netdoc: fix `clippy::len_zero`Steven Engler2025-04-031-1/+1
| | | | | | | | | | | | | | | | | | ```text warning: length comparison to one --> crates/tor-netdoc/src/parse/tokenize.rs:470:12 | 470 | if args.len() >= 1 { | ^^^^^^^^^^^^^^^ help: using `!is_empty` is clearer and more explicit: `!args.is_empty()` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#len_zero note: the lint level is defined here --> crates/tor-netdoc/src/lib.rs:9:9 | 9 | #![warn(clippy::all)] | ^^^^^^^^^^^ = note: `#[warn(clippy::len_zero)]` implied by `#[warn(clippy::all)]` ```
* netdoc: Reject BOMs and NULs.Nick Mathewson2025-03-171-2/+49
| | | | | | | | | | | | Per <https://spec.torproject.org/dir-spec/netdoc.html>, our netdocs never have a BOM, and never have internal NULs. This makes Arti reject such documents. For arguments on why it's okay to increase parser strictness, see the (forthcoming) proposal 356 at torspec!342, and see older discussion at torspec#296. Closes #1739.
* netdoc: Make some parsing init functions fallible.Nick Mathewson2025-03-172-11/+12
| | | | | | | I'm about to make our parsers reject some strings at construction time, so it makes sense to have these functions become fallible. This is a breaking change.
* Fix incorrect doc comment.Wesley Aptekar-Cassels2024-10-091-1/+2
| | | | | | Looks like a copy/paste error. Co-authored-by: Micah Elizabeth Scott <[email protected]>
* Fix "clippy::manual-pattern-char-comparison" warning on nightlyNick Mathewson2024-07-281-1/+1
| | | | | | | This warning suggests using `[a,b]` as a Pattern when it sees a search for `|ch| ch == a || ch == b`. (All of our supported rust versions allow this kind of Pattern.)
* Run maint/add_warning.Nick Mathewson2024-03-132-0/+2
|
* clippy: Replace many calls to .get(0) with .first()Ian Jackson2024-01-021-1/+1
| | | | | FTR I don't think agree with clippy on this question, but then I often don't.
* netdoc: Remove an "unknown_lints" exception.Nick Mathewson2023-11-301-1/+0
|
* Run maint/add_warning to add lint block everywhereIan Jackson2023-08-232-0/+2
|
* Run maint/add_warning to actually apply new lint allowsIan Jackson2023-07-102-0/+2
|
* netdoc: Rename parse_error_kind() to netdoc_error_kind().Gabriela Moldovan2023-05-112-4/+4
| | | | | | | `ParseErrorKind` was renamed to `NetdocErrorKind`, so we need to rename this acccessor too. Signed-off-by: Gabriela Moldovan <[email protected]>
* netdoc: Rename `ParseError{Kind, Source}` to `NetdocError{Kind, Source}`.Gabriela Moldovan2023-05-103-7/+7
| | | | | | | | | | | `ParseErrorSource` was originally meant to represent a parsing error, this enum has since gained some variants that aren't really parsing related (`Signature`, `CertSignature`, `UntimelyDescriptor`). Since this error type is now used for general-purpose netdoc errors, let's rename `ParseError{Kind, Source}` to `NetdocError{Kind, Source}`. Signed-off-by: Gabriela Moldovan <[email protected]>
* Rename onion-* cargo features to hs-* in tor-* cratesIan Jackson2023-02-281-1/+1
| | | | Fixes #756
* tor-netdoc: Run rustfmt (separately from the refactoring)Ian Jackson2023-02-151-3/+1
|
* tor-netdoc: Abolish NetDocReader::iter and into_iterIan Jackson2023-02-151-13/+0
| | | | Nothing uses these now; the NetDocReader is simply an iterator, itself.
* tor-netdoc: Remove many needless calls to .iter() and .into_iter()Ian Jackson2023-02-152-11/+12
|
* tor-netdoc: Use impl Iterator for NetdocReader in .pause_atIan Jackson2023-02-151-2/+2
| | | | This simplifies the return type!
* tor-netdoc: impl Iterator etc. for NetdocReaderIan Jackson2023-02-151-0/+29
| | | | This will simplify things at many call sites.
* tor-netdoc: Use itertools to implement NetDocReader::pause_atIan Jackson2023-02-151-7/+11
| | | | This is the last use of PauseAt.
* tor-netdoc: Have sectionrules.parse take I, not &mut IIan Jackson2023-02-151-2/+2
| | | | | | There's a blanket impl of Itertor for &mut impl Iterator, so this isn't necessary, and it prevents us passing iterators by value producing syntactic vinegar.
* tor-netdoc: Import Peekable rather than referring to it by pathIan Jackson2023-02-151-3/+4
| | | | | This makes things easier to read. We're about to add another site (albeit, temporarily).
* tor-netdoc: Use batching iterator in authcert.rsIan Jackson2023-02-101-1/+1
| | | | | This gets rid of a lot of manual boolean state variable iterator stuff.
* tor-netdoc: Provide NetDocReader::into_iterIan Jackson2023-02-101-0/+7
| | | | | This will avoids some hairy borrowck disasters when we try to use iterator adapters.
* netdoc: Require that unrecognized tokens be handled explicitly.Nick Mathewson2023-02-031-5/+29
| | | | | | | | | | | | | | | | | | | | | | | | Now we require that, for all `SectionRules`, either the caller say how to handle unrecognized tokens (using `.add(UNRECOGNIZED...)`), or that they explicitly reject unrecognized tokens (using `reject_unrecognized`()`.) This solution uses an assert!() rather than an Error to indicate failure. I say that's fine, since 1. This is a crate-internal API. 2. We never dynamically construct SectionRules according to different behavior: they are always prefabricated in a fixed code block. Thus, if we test a parser at all, we will make sure that its SectionRules are well-formed. I considered and explicitly rejected a solution where the builder had to be finalized with separate methods `build_strict()` or `build_tolerant()`: It's too easy IMO for the caller to forget what these call means. Prevents further recurrences of #752. Closes #752.
* netdoc: Switch SectionRules building to use a Buidler pattern.Nick Mathewson2023-02-031-15/+29
| | | | No new behavior yet.
* tor-netdoc: Suppress a cfg-dependent dead code warningIan Jackson2023-02-011-0/+1
| | | | | This is dead code when cargo +stable clippy -p tor-netdir --all-features --all-targets
* Allow clippy::unchecked_duration_subtraction in testsNick Mathewson2023-01-272-0/+2
| | | | | This panics on error, and we're fine with a panic on misbehavior in tests.
* Elide a bunch of lifetimes.Nick Mathewson2023-01-272-6/+6
| | | | | Clippy now warns about these; I'm not sure how these warnings snuck up on us.
* netdoc builder: Implement object() and add one test caseIan Jackson2023-01-241-1/+0
|