aboutsummaryrefslogtreecommitdiff
path: root/crates/tor-netdoc/src/parse/tokenize.rs
Commit message (Collapse)AuthorAgeFilesLines
* Removed unnecessary lintpryty262026-07-151-1/+0
| | | | Removed unnecessary lint
* 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-091-0/+1
| | | | | | | | | | | | 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: 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-061-1/+1
| | | | Run maint/add_warning
* 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: 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-171-9/+10
| | | | | | | 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 "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-131-0/+1
|
* Run maint/add_warning to add lint block everywhereIan Jackson2023-08-231-0/+1
|
* Run maint/add_warning to actually apply new lint allowsIan Jackson2023-07-101-0/+1
|
* netdoc: Rename parse_error_kind() to netdoc_error_kind().Gabriela Moldovan2023-05-111-2/+2
| | | | | | | `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-101-4/+4
| | | | | | | | | | | `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-151-7/+8
|
* 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: 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.
* 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-271-0/+1
| | | | | This panics on error, and we're fine with a panic on misbehavior in tests.
* netdoc builder: Implement object() and add one test caseIan Jackson2023-01-241-1/+0
|
* tor-netdoc: tokenize: Provide BASE64_PEM_MAX_LINEIan Jackson2023-01-241-0/+3
| | | | We'll use this in the netdoc builder, but it naturally lives here.
* tor-netdoc: tokenize: Rename to tag_keywords_ok, document, exposeIan Jackson2023-01-241-3/+3
| | | | | | | | | Rename from _keyword_, since this actually checks the *multiple* keywords that can appear in an object's BEGIN line. Make this clear in the doc comment. Expose it for use by the netdoc builder.
* tor-netdoc: tokenize: crate-Expose object::BEGIN_STR etc.Ian Jackson2023-01-241-6/+11
| | | | The document builder wants these too.
* test lint blocks: Do some semi-manuallyIan Jackson2022-12-121-0/+8
| | | | | | | This is the hunks from running the rune in maint/adhoc-add-lint-blocks but which require some subsequent manual fixup: usually, deleting now-superfluous outer allows, but in some cases manually putting back lints that the adhoc script deleted.
* Fix a couple of rustdoc issues.Nick Mathewson2022-11-181-2/+2
| | | | These slipped in while nightly was broken.
* Resolve a dead-code warning.Nick Mathewson2022-11-151-0/+1
|
* netdoc: Allow empty lines at the end of a router descriptor.Nick Mathewson2022-11-151-0/+24
|
* tor-netdoc: Add a new ErrorKind for EmptyLine.Nick Mathewson2022-11-151-1/+4
| | | | | Empty lines were previously reported as BadKeyword, which is confusing.
* Fix some rustdoc errors.Nick Mathewson2022-10-131-2/+2
| | | | | | In addition to the usual "You named that method wrong!" errors, we have a new rustdoc error that complains about bogus "HTML tags" that are actually unquoted usage of types like `Result<Foo>`.
* Replace `base64` crate with `base64ct` crateArturo Marquez2022-06-211-3/+3
| | | | | | | Note: the `base64ct` crate rejects invalid characters when the decoding is done on padded strings. However, the `FromStr` impl for `B64` can have both padded **and** unpadded inputs, so all inputs are now padded first, before decoding.
* netdoc: remove an unused method.Nick Mathewson2022-06-071-12/+0
|
* Refactor tor_netdoc::ErrorNick Mathewson2022-02-141-32/+40
| | | | | | | | | | | | | | | This error type doesn't impement HasKind, since the kind will depend on context. However, the existing implementation was pretty messy and inconsistent: Some errors had positions, some didn't. Some took messages as str, some as String. Some had internal errors that were somewhat orthogonal to their actual types. This commit refactors tor_netdoc::Error to use a ParseErrorKind, and adds a set of convenience functions to add positions and messages to the errors that need them.
* clippy: Suppress a warningIan Jackson2022-01-191-0/+3
|