Skip to content

The --wide- and --tiny- alias prefixes drop the connection count they exist to add - #1424

Open
xroche wants to merge 3 commits into
masterfrom
fix-alias-addcommand-dropped
Open

The --wide- and --tiny- alias prefixes drop the connection count they exist to add#1424
xroche wants to merge 3 commits into
masterfrom
fix-alias-addcommand-dropped

Conversation

@xroche

@xroche xroche commented Aug 24, 2026

Copy link
Copy Markdown
Owner

The --wide- and --tiny- prefixes build the connection count they exist to add and then drop it: optalias_check() writes c32 or c1 into a local buffer nothing reads, so --wide-mirror is --mirror at 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, --tiny and --ultrawide as standalone presets, and neither the man page nor the help mentions the prefixed spellings. They are live all the same, since optreal_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-mirror becomes -wc32 and --tiny-spider becomes -p0C0I0tc1. The value comes from the --wide and --tiny rows 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: -#hc32 misses the whole-word match on -#h, so --wide-version printed the usage dump instead of the version; -N%h%p/%n.%tc32 corrupts the user's template and drops the count anyway; and --wide-sockets 8 became -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 -%r plus a c is the -%rc of --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:

* Warning: the wide- prefix cannot add its connection count to --path, so --path runs without it; write --wide --path instead

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-warc and 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 1 at src/htsalias.c:347 switches to it, and the expectations in st_optalias (WARNS back to REFUSES) 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-structure keeps laying out by its template, --wide-sockets 8 stays at 8, --wide-warc still writes an archive, --tiny-wide still gets 32, --wide-version still prints the version. -#test=optalias pins 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

xroche and others added 3 commits August 24, 2026 23:12
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>
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.

The --wide- and --tiny- alias prefixes drop the connection count they exist to add

1 participant