Skip to content

Commit

Permalink
regex is hard but I do not want to couple to RE here :-(
Browse files Browse the repository at this point in the history
---
 Signed-off-by: Peter Kriens <[email protected]>

Signed-off-by: Peter Kriens <[email protected]>
  • Loading branch information
pkriens committed Feb 7, 2024
1 parent 44a4a7b commit 26dcceb
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion aQute.libg/src/aQute/lib/io/Windows.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

class Windows implements OS {
final static Pattern WINDOWS_BAD_FILE_NAME_P = Pattern.compile(
"(?:(:?.*[\u0000-\u001F<>:\"|/\\\\?*].*)|..|CON|PRN|AUX|NUL|COM\\d|COM¹|COM²|COM³|LPT\\d|LPT¹|LPT²|LPT³)(?:\\.\\w+)?",
"(?:(:?.*[\u0000-\u001F<>:\"|/\\\\?*].*)|\\.\\.|CON|PRN|AUX|NUL|COM\\d|COM¹|COM²|COM³|LPT\\d|LPT¹|LPT²|LPT³)(?:\\.\\w+)?",
Pattern.CASE_INSENSITIVE);

@Override
Expand Down
4 changes: 4 additions & 0 deletions aQute.libg/test/aQute/lib/io/IOTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -561,6 +561,8 @@ public void testGetBasedFile() throws IOException {
assertThat(new File(base, "")).isEqualTo(base);
assertThat(new File(base, "./").getParentFile()).isEqualTo(base);
assertThat(new File(base, "/bar").getParentFile()).isEqualTo(base);
assertThat(IO.getBasedFile(base, "META-INF/versions/11/OSGI-INF/MANIFEST.MF")
.getName()).isEqualTo("MANIFEST.MF");
assertThat(IO.getBasedFile(base, "")).isEqualTo(base);
assertThat(IO.getBasedFile(base, "foo/../bar")).isEqualTo(new File(base, "bar"));
assertThat(IO.getBasedFile(base, ".💩.")).isEqualTo(new File(base, ".💩."));
Expand All @@ -578,6 +580,8 @@ public void testCoder() {
public void testWindows() throws IOException {
Windows os = new Windows();
File base = new File("base").getAbsoluteFile();
assertThat(os.getBasedFile(base, "META-INF/versions/11/OSGI-INF/MANIFEST.MF")
.getName()).isEqualTo("MANIFEST.MF");
assertThat(except(() -> os.getBasedFile(base, "bar/LPT1"))).contains("io.win.sub.invalid");
assertThat(except(() -> os.getBasedFile(base, "bar/<bla"))).contains("io.win.sub.invalid");
assertThat(except(() -> os.getBasedFile(base, "bar/>bla/foo"))).contains("io.win.sub.invalid");
Expand Down

0 comments on commit 26dcceb

Please sign in to comment.