Path argument containing `//` duplicates the preceding component (`d//c.txt` → `d/d/c.txt`); `a` and `h` silently use a different file
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 55/100
Direzione di ricerca
Start with CPP/Common/Wildcard.cpp at SplitPathToParts() and CCensor::AddItem(), then trace the empty-component handling in CPP/7zip/UI/Common/EnumDirItems.cpp around lines 998–1043. Reproduce with the supplied d//c.txt commands and inspect existing path normalization tests. Done means repeated slashes no longer select a different file and exclusion and folder enumeration behave consistently.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Environment
- 7-Zip (z) 26.06 (arm64),
ip7z/7zip@d3296e3, built withCPP/7zip/cmpl_mac_arm64.mak(Bundles/Alone2) - macOS 26.4.1 arm64, Apple clang 21.0.0
Steps to reproduce
d=$(mktemp -d) && cd "$d"
mkdir -p d/d
printf xyz > d/c.txt # CRC32 EB8EBA67
printf other > d/d/c.txt # CRC32 D9583520
7zz h -bd d//c.txt # prints: D9583520 5 d/d/c.txt <- wrong file
7zz h -bd d/c.txt # prints: EB8EBA67 3 d/c.txt
7zz a -bd t.7z d//c.txt; 7zz l -slt t.7z | grep -E '^(Path|CRC)'
# Path = d/d/c.txt CRC = D9583520 <- wrong file archived, rc=0
Without d/d/c.txt:
rm -r d/d
7zz h -bd d//c.txt # WARNING: errno=2 : No such file or directory d/d/c.txt ; Files: 0 ; rc=1
7zz h -bd d// # lists a phantom folder "d/d/"
Exclusion does not work:
printf q > d/k.txt
7zz h -bd '-x!d//c.txt' 'd/*' # d/c.txt is still hashed (Files: 2)
7zz h -bd '-x!d/c.txt' 'd/*' # d/c.txt excluded (Files: 1)
Expected
On POSIX, "multiple successive slashes are considered to be the same as one slash" (POSIX.1-2017 XBD 4.13 Pathname Resolution). 7-Zip's documentation gives // no special meaning, and 7-Zip already normalizes ./ and a single trailing /. So d//c.txt should mean d/c.txt. At the very least it should never select a different existing file.
Root cause (analysis on d3296e3)
CPP/Common/Wildcard.cpp:158SplitPathToParts()splitsd//c.txtinto["d", "", "c.txt"].CCensor::AddItem()(Wildcard.cpp:607onward) removes only a trailing empty part, so an empty-named node remains betweendandc.txt.CPP/7zip/UI/Common/EnumDirItems.cpp:998-1043: for the empty-named child,FindFileis called withfullPath = phyPrefix("d/"). The returnedfi.Nameis"d". Enumeration then recurses withcurFolderName = "d", so the physical prefix becomesd/d/.
Suggested fix
Drop empty path components (//) when splitting user-supplied paths on POSIX, before building the censor tree. An empty component in the middle of a path has no meaning there.
Related
- #55: the maintainer states that a leading
./is stripped on purpose ("7-zip removes path prefixes for absolute paths and for paths starting from./"). A//in the middle of a path is a different case: it is not a prefix, and it makes 7-Zip pick a different file. - #175: path normalization of
..with symlinks on Linux.
Found with a differential test setup (a model of the documented behavior compared against the real binary) and then checked by hand: every command above was re-run verbatim on the tested build, and the root cause was read in the source. Tested commit: d3296e3 (26.06).
- Lingua principale
- C++
- Stelle
- 4.6k
- Fork
- 519
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Preparare l'ambiente
Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di ip7z/7zip
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
I maintainer di solito rispondono entro 1 giorno
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 74/100
I maintainer di solito rispondono entro 1 giorno
-
area::installer documentation engine::sd enhancement wg::platform-core
Difficoltà 2/5 1-3 ore Idoneità per principianti 67/100
lemonade-sdk/lemonade#4349 ·
I maintainer di solito rispondono entro 1 giorno
-
Python example: list a model's scenes and their camerasForse già presa @rudraparmar76 l’ha presa oggi. Apertadocumentation good first issue python
Difficoltà 2/5 1-3 ore Idoneità per principianti 85/100
iamahsanmehmood/openskp#796 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
tenstorrent/tt-umd#4183 ·
I maintainer di solito rispondono entro 4 giorni
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
odelaneau/GLIMPSE#353 · 1 commento ·
I maintainer di solito rispondono entro 4 giorni