The --wide- and --tiny- alias prefixes drop the connection count they exist to add - #1424
Open
xroche wants to merge 3 commits into
Open
The --wide- and --tiny- alias prefixes drop the connection count they exist to add#1424xroche wants to merge 3 commits into
xroche wants to merge 3 commits into
Conversation
optalias_check() built the -c count the prefix exists to add and never read the buffer holding it, so --wide-mirror expanded to a bare -w and crawled at the default connection count. Glue the count onto the short form the alias expands to (-wc32), reading the value from the --wide and --tiny rows instead of a second copy of it, and refuse the prefix on an alias with nowhere to put it rather than dropping it again. Closes #1423 Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Signed-off-by: Xavier Roche <xroche@gmail.com>
Gluing -c32 onto whatever the alias expanded to broke three ways: -#hc32 misses the whole-word match on -#h, -N%h%p...c32 corrupts the template and drops the count again, and -c8c32 quietly means 32. Restrict the glue to the plain letter-and-digit clusters and refuse the prefix everywhere else, which is the honest reach of a feature that was never finished. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Signed-off-by: Xavier Roche <xroche@gmail.com>
Refusing the option turned 256 released spellings into exit 255 to fix a count that has been dropped since 2001. Apply the base alias without the count and say so on stderr instead, so nothing that runs today stops running. The refusal is kept behind OPTALIAS_PREFIX_STRICT for whoever prefers it. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Signed-off-by: Xavier Roche <xroche@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The
--wide-and--tiny-prefixes build the connection count they exist to add and then drop it:optalias_check()writesc32orc1into a local buffer nothing reads, so--wide-mirroris--mirrorat the default four connections. The write is dead in the initial 3.20.2 import, so this is an unfinished feature rather than a regression, and nothing documents the prefix: cmdguide lists--wide,--tinyand--ultrawideas standalone presets, and neither the man page nor the help mentions the prefixed spellings. They are live all the same, sinceoptreal_or_alias()already treats--wide-<alias>as an option name and 275 passes one around as one.The count is glued onto the short form the alias expands to, the way the table writes its own clusters:
--wide-mirrorbecomes-wc32and--tiny-spiderbecomes-p0C0I0tc1. The value comes from the--wideand--tinyrows rather than a second copy of 32 and 1. Gluing is only safe where the expansion is a plain letter-and-digit cluster, and an earlier draft of this branch glued everywhere, which broke three ways:-#hc32misses the whole-word match on-#h, so--wide-versionprinted the usage dump instead of the version;-N%h%p/%n.%tc32corrupts the user's template and drops the count anyway; and--wide-sockets 8became-c8c32, silently 32. The rule now admits 44 of the 172 alias names, excluding the classes whose value shares or owns the word, long forms, the-%and-#families (whose option names are not self-delimiting, so-%rplus acis the-%rcof--warc-cdx), a cluster already carrying-c, and-h.On the other 128 the alias applies without the count and HTTrack says so on stderr, rather than dropping it in silence as before:
A choice to make, and the branch is on the safer side of it. The alternative is to refuse those spellings outright, which reads well ("do not silently ignore what the user asked for") but turns 256 spellings shipped since 3.48.10 from running to exit 255:
--wide-path /out,--tiny-allow '*.gif',--wide-user-agent X,--wide-clean,--wide-sockets 8,--wide-structure,--wide-cache,--wide-proxy,--wide-version,--wide-warcand 118 more names. As pushed, nothing that runs today stops running and no output changes beyond the warning line. The refusal path is still there and tested:#define OPTALIAS_PREFIX_STRICT 1at src/htsalias.c:347 switches to it, and the expectations inst_optalias(WARNSback toREFUSES) and in 361 follow.The new test asserts the argv echo hts-log.txt writes on its second line, which is the word the engine was handed, then the security limiter's clamp line, which is the count reaching the option rather than just the rebuilt argv. It covers one warned spelling from each excluded class and checks the base alias still did its job:
--wide-structurekeeps laying out by its template,--wide-sockets 8stays at 8,--wide-warcstill writes an archive,--tiny-widestill gets 32,--wide-versionstill prints the version.-#test=optaliaspins the exact expansion of every accepted and warned spelling, and asserts no unprefixed alias warns. All 172 names were swept twice against the built binary, with and without a URL: the 44 glue with the right echo and no warning, the 128 warn and are otherwise indistinguishable from the unprefixed run.Closes #1423