Repository navigation
ZipContent.Entry hasNameStartingWith ignores the offset of virtualized nested directory names - #52299
Merged
wilkinsona merged 1 commit intoOct 27, 2026
Conversation
`ZipContent.Entry#hasNameStartingWith` reads the name directly from the central directory record, but doesn't take into account the offset of names that are virtualized for nested directory content. For such entries the prefix is compared with the complete name, including the directory, so the method returns `false` for a name that `getName()` returns, and the result depends on whether `getName()` was called first to populate the cache. Apply the same offset that is used by `getName()`. Signed-off-by: zhoubiao188 <32508238+zhoubiao188@users.noreply.github.com> See spring-projectsgh-52299
wilkinsona
force-pushed
the
fix-loader-nested-entry-name-prefix
branch
from
October 27, 2026 14:13
71bdb8c to
9e15e9a
Compare
Member
|
Thanks again, @zhoubiao188. |
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.
When
ZipContentis opened for a nested directory (Kind.NESTED_DIRECTORY), entry names are virtualized: the name stored in the central directory record includes the directory name, whilegetName()strips it usingnameOffsetLookups.hasNameStartingWithreads the record directly but doesn't strip the same offset, so it compares the prefix with the complete name.For a nested directory
d/containing9.dat,getName()returns9.dat, buthasNameStartingWith("9.dat")returnsfalseuntilgetName()happens to have been called:This contradicts the method's own contract and makes the result depend on call order. It also prevents
MetaInfVersionsInfofrom seeing versioned entries in nested directory content, because it relies onhasNameStartingWith("META-INF/versions/").Fix
Apply the same
nameOffsetLookupsoffset thatgetName()uses. A regression test is included.