Skip to content

Commit

Permalink
Fixes filenames by not allowing curly braces
Browse files Browse the repository at this point in the history
  • Loading branch information
Siedlerchr committed Feb 10, 2020
1 parent ec154f6 commit 212fbef
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ We refer to [GitHub issues](https://github.com/JabRef/jabref/issues) by using `#

- We cleaned up the group add/edit dialog. [#5826](https://github.com/JabRef/jabref/pull/5826)
- We reintroduced the index column. [#5844](https://github.com/JabRef/jabref/pull/5844)
- Filenames of external files can no longer contain curly braces


### Fixed

Expand All @@ -30,6 +32,8 @@ We refer to [GitHub issues](https://github.com/JabRef/jabref/issues) by using `#
- We fixed an issue where cleaning up entries broke web URLs, if "Make paths of linked files relative (if possible)" was enabled, which resulted in various other issues subsequently. [#5861](https://github.com/JabRef/jabref/issues/5861)
- We fixed an issue where the tab "Required fields" of the entry editor did not show all required fields, if at least two of the defined required fields are linked with a logical or. [#5859](https://github.com/JabRef/jabref/issues/5859)
- We fixed several issues concerning managing external file types: Now everything is usable and fully functional. Previously, there were problems with the radio buttons, with saving the settings and with loading an input field value. Furthermore, different behavior for Windows and other operating systems was given, which was unified as well. [#5846](https://github.com/JabRef/jabref/issues/5846)
- We fixed an issue where entries containing Unicode charaters were not parsed correctly [#5899](https://github.com/JabRef/jabref/issues/5899)
- We fixed an issue where an entry containing an external filename with curly braces could not be saved. Curly braces are now longer allowed in filenames. [#5899](https://github.com/JabRef/jabref/issues/5899)

### Removed
- Ampersands are no longer escaped by default in the `bib` file. If you want to keep the current behaviour, you can use the new "Escape Ampersands" formatter as a save action.
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/org/jabref/logic/util/io/FileNameCleaner.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

/**
* This class is based on http://stackoverflow.com/a/5626340/873282
*
* extended with LEFT CURLY BRACE and RIGHT CURLY BRACE
* Replaces illegal characters in given file paths.
*/
public class FileNameCleaner {
Expand All @@ -21,7 +21,7 @@ public class FileNameCleaner {
42,
58,
60, 62, 63,
124
123, 124, 125
};
// @formatter:on

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,9 @@ public void testCleanDirectoryNameForWindows() {
assertEquals("subdir\\legalFilename.txt", FileNameCleaner.cleanDirectoryName("subdir\\legalFilename.txt"));
assertEquals("illegalFilename\\_____.txt", FileNameCleaner.cleanDirectoryName("illegalFilename\\?*<>|.txt"));
}

@Test
public void testCleanCurlyBracesAsWell() {
assertEquals("The Evolution of Sentiment_ Analysis_A Review of Research Topics, Venues, and Top Cited Papers.PDF", FileNameCleaner.cleanFileName("The Evolution of Sentiment} Analysis}A Review of Research Topics, Venues, and Top Cited Papers.PDF"));
}
}

0 comments on commit 212fbef

Please sign in to comment.