You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Fix placeholder corruption and improve classpath boundary checks - #377
This pull request addresses two main areas: it improves the robustness of class path matching in URLUtils to avoid false positives, and fixes an issue in string formatting where argument values containing placeholders could be incorrectly replaced. Comprehensive regression tests have been added for both issues.
Class Path Matching Improvements:
Introduced the isResourcePathOnClassPath method in URLUtils, which uses canonical paths and path-separator boundaries to accurately determine if a resource is under a class path, preventing false matches like /opt/app matching /opt/application. Updated resolveArchiveDirectory to use this method.
Added extensive unit tests in URLUtilsTest to verify correct behavior for various path cases, including real file system paths and edge cases.
String Formatting Fixes:
Modified FormatUtils.formatWithPlaceholder so that argument values containing the placeholder (e.g. "x{}y") are not corrupted by subsequent replacements, by tracking the replacement cursor.
Added regression tests in FormatUtilsTest to ensure placeholders inside argument values are handled correctly, including cases with more placeholders than arguments and custom placeholders.
Other Minor Updates:
Added missing imports in test and source files for new functionality. [1][2][3]
Update `FormatUtils` replacement logic to search after each inserted value, preventing argument values containing placeholders from being replaced by later arguments. Add regression coverage for default and custom placeholders.
Replaced substring-based classpath matching with canonical path boundary checks when resolving archive directories, preventing false positives like "/opt/app" matching "/opt/application". Added focused regression tests for issue #318, including canonical path normalization cases, real temp-directory paths, and archive directory resolution behavior for both classpath and non-classpath resources.
The reason will be displayed to describe this comment to others. Learn more.
🟡 Changes recommended
Classpath matching regressions cause resolveArchiveFile to return null for valid resources under filesystem-root classpaths and Windows file URLs, requiring path normalization fixes and regression tests.
The reason will be displayed to describe this comment to others. Learn more.
🔵 Needs a closer look
File URL paths are canonicalized without decoding, causing valid resources in space-containing directories to be rejected and encoded parent-directory segments to incorrectly match the classpath.
With relative classpath classes and working directory /tmp/my app, buildPath(resourceURL) supplies /tmp/my%20app/classes/Foo.class; canonicalization leaves %20 intact, so the new comparison rejects a valid resource and resolveArchiveFile() returns null. The same encoding mismatch lets /opt/app/%2e%2e/application/Foo.class incorrectly match classpath /opt/app. Convert the file URL to a decoded filesystem path before canonicalizing, preserving literal + characters, and add regression tests for escaped parent directories and encoded .. segments.
Review effort: Balanced
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
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.
This pull request addresses two main areas: it improves the robustness of class path matching in
URLUtilsto avoid false positives, and fixes an issue in string formatting where argument values containing placeholders could be incorrectly replaced. Comprehensive regression tests have been added for both issues.Class Path Matching Improvements:
isResourcePathOnClassPathmethod inURLUtils, which uses canonical paths and path-separator boundaries to accurately determine if a resource is under a class path, preventing false matches like/opt/appmatching/opt/application. UpdatedresolveArchiveDirectoryto use this method.URLUtilsTestto verify correct behavior for various path cases, including real file system paths and edge cases.String Formatting Fixes:
FormatUtils.formatWithPlaceholderso that argument values containing the placeholder (e.g."x{}y") are not corrupted by subsequent replacements, by tracking the replacement cursor.FormatUtilsTestto ensure placeholders inside argument values are handled correctly, including cases with more placeholders than arguments and custom placeholders.Other Minor Updates: