-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Fix: Make FileUtil.relativize symlink-aware #13553
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…ion and OpenSelectedEntriesFilesAction - Introduced OpenSingleExternalFileAction to handle single entry with one linked file - Introduced OpenSelectedEntriesFilesAction to handle multiple selection cases Fixes JabRef#13431
…13505) Bumps [org.junit.platform:junit-platform-launcher](https://github.com/junit-team/junit-framework) from 1.13.1 to 1.13.3. - [Release notes](https://github.com/junit-team/junit-framework/releases) - [Commits](https://github.com/junit-team/junit-framework/commits) --- updated-dependencies: - dependency-name: org.junit.platform:junit-platform-launcher dependency-version: 1.13.3 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Oliver Kopp <kopp.dev@gmail.com>
…resolution - Use real/canonical paths to ensure files are correctly recognized as within a directory, even through symlinks - Add and document unit tests covering symlinked and normal directory scenarios fixes JabRef#12995
…Path and remove unnecessary comments
…bref into fix-for-issue-12995
Hi! I’ve pushed the requested changes, and it looks like all checks have passed. Just checking in to see if there's anything more I should do. Thanks again for guiding me through this! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see a test I've put in the issue description.
I am not sture if the algorithm works. I am not sure how symlinks are really ersolved on Linux on edge cases.
jablib/src/test/java/org/jabref/logic/util/io/FileUtilTest.java
Outdated
Show resolved
Hide resolved
jablib/src/test/java/org/jabref/logic/util/io/FileUtilTest.java
Outdated
Show resolved
Hide resolved
… simplicity, and ensured all edge cases from issue JabRef#12995 are now covered.
Note that there is no test for #12995 (comment) - it would be OK to have it ignored. Not sure how important this is, but it should be noted down somewhere. Maybe a link js enough. |
I used RefactoringMiner to review The logic diff is as follows ![]() And test case ![]() There were some syntax changes; I try to look. Refs JabRef#672. |
@Muskan244 Why didn't you add a CHANGELOG.md entry?! |
private static Optional<Path> tryRealPath(Path path) { | ||
if (Files.exists(path)) { | ||
try { | ||
return Optional.of(path.toRealPath()); | ||
} catch (IOException e) { | ||
return Optional.empty(); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The method catches IOException and returns Optional.empty() instead of letting the exception propagate. This uses exceptions for control flow which is against best practices.
@trag-bot didn't find any issues in the code! ✅✨ |
Follow-up would be to spleit the parameterized test into seperate test cases - the method producing the arguments is not very readable. |
Thanks! I’ll prepare a follow-up PR for splitting the parameterized test into separate test cases to make it more readable. |
* upstream/main: New translations jabref_en.properties (Italian) (#13725) Minor code style updates (#13722) Fix: Make FileUtil.relativize symlink-aware (#13553) New Crowdin updates (#13720) Bump org.glassfish.jersey.core:jersey-server in /versions (#13714) Enable UseObjectNotifyAll (#13718) Bump com.dlsc.gemsfx:gemsfx from 3.3.5 to 3.4.2 in /versions (#13717) Update on-issue-comment.yml Bump org.openrewrite.recipe:rewrite-recipe-bom from 3.12.1 to 3.13.0 (#13716) Bump org.openrewrite.rewrite from 7.12.1 to 7.14.0 (#13715) Bump org.glassfish.jersey.inject:jersey-hk2 in /versions (#13713) feat(git): add “Share to GitHub” flow (#13677) Bump jablib/src/main/resources/csl-styles from `292aec3` to `1194364` (#13712) Bump jablib/src/main/abbrv.jabref.org from `cfe719f` to `a97f9c6` (#13711) Bump jablib/src/main/resources/csl-locales from `e2de1e3` to `fa56de1` (#13710) Add noop Git Config System Reader to prevent usage of real world stuff into jgit (#13703) Added static (stream & preferences) constructors to BibDatabaseContext (#13694) New Crowdin updates (#13698) fix git modules requires and uses (#13696) Focus "Specify Bib(La)TeX" when Bib(La)TeX is in clipboard (#13633)
Closes #12995
This PR to make FileUtil.relativize symlink-aware by:
Updating
FileUtil::relativize
to handle symlinks when resolving relative paths.Ensuring files inside symlinked directories are correctly referenced by their relative path.
Adding unit tests to verify correct behavior with symlinked and regular directories.
Adding ignored test for symlink escape scenario (/lib/things -> /share/expensive -> /veryprivate).
Steps to test
Gradle: ./gradlew test
Ensure all tests in FileUtilTest related to symlink handling pass without errors.
Mandatory checks
CHANGELOG.md
described in a way that is understandable for the average user (if change is visible to the user)