summaryrefslogtreecommitdiff
path: root/crates/tor-netdoc/src/parse
Commit message (Collapse)AuthorAgeFilesLines
* 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
|
* 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: Add many many automaticallyIan Jackson2022-12-121-0/+8
| | | | | This is precisely the result of running the rune in maint/adhoc-add-lint-blocks.
* 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.
* Fix a bunch of "needless borrow" warnings on nightlyNick Mathewson2022-11-181-1/+1
| | | | | It looks like, despite a few false starts, they've got this warning right; there weren't any false positives.
* Replace `Option<Pos>` with `Pos` in `ParseError`.Nick Mathewson2022-11-151-1/+3
| | | | | | | | | | | | | | | We already have `Pos::Unknown` for an error at an unknown location and `Pos::None` for an error where no location is sensible. There's no reason to have an additional `Option` here. Additionally, the use of `Option` gave us a bug where our old `ParseError::at_pos()` method didn't actually set the position unless the position was already set. That's not what we want! Fixes #640. Finally, we have to fix a test that was a bit broken because it was working around #640.
* 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.
* Add one more "allow" to tor_netdoc::parse::macros.Nick Mathewson2022-06-151-0/+1
| | | | | Without this, clippy is error-free, but `cargo test` somehow gives a warning.
* Netdoc: test enforcement for items that mustn't take objects.Nick Mathewson2022-06-071-0/+6
| | | | Found via coverage.
* netdoc: remove an unused method.Nick Mathewson2022-06-071-12/+0
|
* netdoc: Test more accessors for tokenized documents.Nick Mathewson2022-06-072-4/+20
|
* lints: Suppress unknown lints in a way that works on nightly tooIan Jackson2022-05-311-2/+4
| | | | This is ridiculous.
* tor-netdoc: Allow suppressing unknown lintsIan Jackson2022-05-271-0/+2
| | | | | We want to supress the unused_macro_rules lint in one place but it's new in Nightly and this triggers yet another lint.
* tor-netdoc: Suppress new "unused_macro_rules" lint in one placeIan Jackson2022-05-271-0/+1
| | | | | | | The compiler can apparently tell that we aren't generating compile errors! Also that we're not yet using a feature provided here. (New lint in currently Nightly.)
* tor-netdoc: Actually, make TokVal be a VecIan Jackson2022-03-111-46/+20
| | | | | This enum was otiose: its set of valid values is precisely those of a Vec. (Indeed what would TokVal::Multi(vec![]) have meant?)
* Remove a pointless sliceIan Jackson2022-03-111-10/+7
| | | | std::slice::from_ref exists. Spotted while reviewing !400
* Refactor tor_netdoc::ErrorNick Mathewson2022-02-143-51/+80
| | | | | | | | | | | | | | | 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
|
* Change an UTF-8 XXX to a TODO.Nick Mathewson2021-12-201-1/+2
| | | | We're assuming that prop285 is accepted in some form.
* address lint warningsDaniel Eades2021-12-091-8/+8
| | | | | [Edited by nickm: This applies one of Daniel's fixes in place of one of Trinity's: Trinity says it's a bit cleaner, and I agree.]
* fix nightly clippy errorsTrinity Pointard2021-12-091-4/+3
|
* add semicolons if nothing returnedDaniel Eades2021-11-251-1/+1
|
* tor-netdoc: Put the "routerdesc" document type behind a feature.Nick Mathewson2021-11-121-0/+1
| | | | | | | | | | Nothing in arti currently uses this document type. Eventually it will be useful for relays and for bridge clients. I've left the "SHA1 digest of a router descriptor" type available unconditinoally, however, since it does get used in a few places. Part of #125.