Skip to content

A packed option flag can be misread as its two-letter variant - #98

Merged
xroche merged 1 commit into
masterfrom
fix-78-unpack
Aug 2, 2026
Merged

A packed option flag can be misread as its two-letter variant#98
xroche merged 1 commit into
masterfrom
fix-78-unpack

Conversation

@xroche

@xroche xroche commented Aug 2, 2026

Copy link
Copy Markdown
Owner

The engine reads a packed -... token one character at a time, so a %r, %m or %Z followed by the wrong letter turns into the two-letter form that eats the next argv token. With WARC on and CheckType empty the packed string spelled %rs, the engine took it for --warc-max-size, and the first crawl URL went with it. Each - token is parsed on its own, so the three SimpleOption* classes and the four merge handlers now emit one token each, and LongOptionFlag (added in #77 to sidestep this for --sitemap, --single-file and --changes) is gone. The shared buffer stays for LogHandler, PrimaryScanHandler and MultipleChoicesOption, whose flags have no two-letter variant.

The digit check and int parse move into a pure OptionValues, which stops MaxSizeHandler and BuildHandler from pulling in OptionsMapper's Android-dependent static init and makes them testable (#81). Mutate the fix back to packing and the new test fails with token -X0%rs2%s spells %rs.

Closes #78

The engine reads a packed -... token one character at a time, so a %r, %m
or %Z followed by the wrong letter turns into the two-letter form that
eats the next argv token. With WARC on and CheckType empty the packed
string spelled %rs, the engine took it for --warc-max-size, and the first
crawl URL went with it.

SimpleOption, SimpleOption0, SimpleOptionFlag and the four merge handlers
now push one token each; LongOptionFlag, which sidestepped this for
--sitemap/--single-file/--changes, is dropped. The shared buffer stays for
the flags with no two-letter variant.

The digit check and int parse move into a pure OptionValues, which stops
MaxSizeHandler and BuildHandler from pulling in OptionsMapper's
Android-dependent static init and makes them testable.

Closes #78

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Signed-off-by: Xavier Roche <roche@httrack.com>
@xroche
xroche merged commit d704768 into master Aug 2, 2026
6 checks passed
@xroche
xroche deleted the fix-78-unpack branch August 2, 2026 08:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

A packed option flag can be misread as its two-letter variant and swallow the crawl URL

1 participant