fix: Enhance cross-platform path parsing and public image access #11152
+633
−15
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 improves the cross-platform compatibility and security of file path handling in the storage service, and strengthens the testing of image download endpoints. The most significant changes include refactoring path parsing to robustly support Windows and Unix-style paths, ensuring the
/imagesendpoint does not require authentication (critical for browser compatibility), and adding comprehensive tests for both functionalities.Path handling improvements:
LocalStorageService.parse_file_pathto usepathlib.Pathfor robust, cross-platform path parsing, ensuring correct behavior on both Windows and Unix systems, and normalizing slashes for consistency. [1] [2]parse_file_pathcovering Windows-style paths, mixed slashes, edge cases, and deeply nested paths to ensure reliability across different platforms and scenarios.Image download endpoint changes:
/imagesendpoint to explicitly not require authentication, with clear documentation explaining the security rationale (UUID-based obscurity) and browser compatibility needs./imagesendpoint remains public, returns correct content types, rejects non-image files, and handles invalid flow IDs gracefully.General improvements: