harden(cac-path-parity): make degenerate mappings inert instead of subtly wrong
Three loose ends from the review, none reachable from entrypoint-lsphp.sh today.
The rewrite semantics and the prefix-boundary logic are untouched; both new
guards only NARROW the set of configurations that do anything, and neither adds
an error path — fail-open is unchanged.
- to="/" produced "//public_html": cacpp_trim() keeps a lone separator, and
the tail already starts with one. Collapse the prefix when there is a tail,
keep it when there is not (value == from exactly, where "/" is correct).
A doubled leading slash is not the same string as the cac-fpm value, which
is the entire point of the extension.
- a non-absolute `from`/`to` was accepted and applied. Both are now required
to start with '/', otherwise RINIT returns exactly as it does for an absent
mapping: inert, no diagnostic, request proceeds.
- a well-formed but WRONG mapping stays undetectable, and now the FAILURE
MODES block says so explicitly rather than leaving it as an unlisted gap,
along with why that is acceptable (the entrypoint derives from/to from the
same two variables it builds the compatibility symlink from, so a wrong
mapping means the symlink is wrong too and the site is already broken more
loudly) and where the only runtime signal is (`lsphp -i`).
Two tests added, both non-vacuous — 007 rewrites without the absolute-path
guard, 008 returns "//public_html" without the collapse. 8/8 pass on PHP
8.1/8.3/8.5, and the FPM harness still reports 9/9 against the changed .so.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
--TEST--
|
||||
cac_path_parity: to=/ does not produce a doubled separator
|
||||
--EXTENSIONS--
|
||||
cac_path_parity
|
||||
--INI--
|
||||
cac_path_parity.from=/mnt/users/bob/site.com
|
||||
cac_path_parity.to=/
|
||||
variables_order=EGPCS
|
||||
--ENV--
|
||||
CONTEXT_DOCUMENT_ROOT=/mnt/users/bob/site.com/public_html
|
||||
--FILE--
|
||||
<?php
|
||||
// Degenerate mapping, unreachable from entrypoint-lsphp.sh (which always writes
|
||||
// to=/home/<user>). Before the eff_to_len collapse this returned
|
||||
// "//public_html". A path with a doubled leading slash is not the same string as
|
||||
// the cac-fpm value, which is the entire point of this extension.
|
||||
var_dump($_SERVER['CONTEXT_DOCUMENT_ROOT']);
|
||||
?>
|
||||
--EXPECT--
|
||||
string(12) "/public_html"
|
||||
Reference in New Issue
Block a user