Skip to content
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

Don't throw exception when validating invalid paths #8112

Merged
merged 4 commits into from
Oct 4, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ Note that this project **does not** adhere to [Semantic Versioning](http://semve
- We fixed an issue where it was impossible to add or modify groups. [#7912](https://github.com/JabRef/jabref/pull/793://github.com/JabRef/jabref/pull/7921)
- We fixed an issue where exported entries from a Citavi bib containing URLs could not be imported [#7892](https://github.com/JabRef/jabref/issues/7882)
- We fixed an issue where the icons in the search bar had the same color, toggled as well as untoggled. [#8014](https://github.com/JabRef/jabref/pull/8014)
- We fixed an issue where typing an invalid UNC path into the "Main file directory" text field caused an error. [#8107](https://github.com/JabRef/jabref/issues/8107)

### Removed

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.jabref.gui.preferences.linkedfiles;

import java.nio.file.Files;
import java.nio.file.InvalidPathException;
import java.nio.file.Path;

import javafx.beans.property.BooleanProperty;
Expand Down Expand Up @@ -55,8 +56,12 @@ public LinkedFilesTabViewModel(DialogService dialogService, PreferencesService p
mainFileDirValidator = new FunctionBasedValidator<>(
mainFileDirectoryProperty,
input -> {
Path path = Path.of(mainFileDirectoryProperty.getValue());
return (Files.exists(path) && Files.isDirectory(path));
try {
Path path = Path.of(mainFileDirectoryProperty.getValue());
return (Files.exists(path) && Files.isDirectory(path));
} catch (InvalidPathException ex) {
return false;
}
},
ValidationMessage.error(String.format("%s > %s > %s %n %n %s",
Localization.lang("File"),
Expand Down