Skip to content

Commit a2ce970

Browse files
committed
Simplify validation condition for manifest paths
Replace the intermediate boolean variable with a single inline condition that checks file existence and path validation in one expression.
1 parent 52535d1 commit a2ce970

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

spring-core/src/main/java/org/springframework/core/io/support/PathMatchingResourcePatternResolver.java

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -634,11 +634,8 @@ private Set<ClassPathManifestEntry> getClassPathManifestEntriesFromJar(File jar)
634634

635635
// For relative paths, enforce security check (must be under parent)
636636
// For absolute paths, just verify file exists (matching JVM behavior)
637-
boolean isValid = pathFile.isAbsolute() ?
638-
candidate.isFile() :
639-
(candidate.isFile() && candidate.getCanonicalPath().contains(parent.getCanonicalPath()));
640-
641-
if (isValid) {
637+
if (candidate.isFile() &&
638+
(pathFile.isAbsolute() || candidate.getCanonicalPath().contains(parent.getCanonicalPath()))) {
642639
manifestEntries.add(ClassPathManifestEntry.of(candidate, this.useCaches));
643640
}
644641
}

0 commit comments

Comments
 (0)