Skip to content

Commit

Permalink
Workaround for snapshot files with not-to-spec slashes.
Browse files Browse the repository at this point in the history
  • Loading branch information
wizjany committed Sep 12, 2020
1 parent 8e53aa0 commit beca3a7
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 6 deletions.
Expand Up @@ -97,10 +97,15 @@ protected InputStream getInputStream(String name, String worldName) throws IOExc
for (Enumeration<? extends ZipEntry> e = zip.entries(); e.hasMoreElements(); ) {
ZipEntry testEntry = e.nextElement();
// Check for world
if (worldPattern.matcher(testEntry.getName()).matches()) {
String entryName = testEntry.getName();
if (worldPattern.matcher(entryName).matches()) {
// Check for file
if (pattern.matcher(testEntry.getName()).matches()) {
folder = testEntry.getName().substring(0, testEntry.getName().lastIndexOf('/'));
if (pattern.matcher(entryName).matches()) {
int endIndex = entryName.lastIndexOf('/');
if (endIndex < 0) {
endIndex = entryName.lastIndexOf('\\');
}
folder = entryName.substring(0, endIndex);
if (folder.endsWith("poi")) {
continue;
}
Expand Down
Expand Up @@ -81,12 +81,18 @@ protected InputStream getInputStream(String name, String worldName) throws IOExc
}
} else {
Pattern pattern = Pattern.compile(".*\\.mc[ra]$");
Pattern worldPattern = Pattern.compile(worldName + "[\\\\/].*");
for (Enumeration<? extends ZipEntry> e = zip.entries(); e.hasMoreElements(); ) {
ZipEntry testEntry = e.nextElement();
// Check for world
if (testEntry.getName().startsWith(worldName + "/")) {
if (pattern.matcher(testEntry.getName()).matches()) { // does entry end in .mca
folder = testEntry.getName().substring(0, testEntry.getName().lastIndexOf('/'));
String entryName = testEntry.getName();
if (worldPattern.matcher(entryName).matches()) {
if (pattern.matcher(entryName).matches()) { // does entry end in .mca
int endIndex = entryName.lastIndexOf('/');
if (endIndex < 0) {
endIndex = entryName.lastIndexOf('\\');
}
folder = entryName.substring(0, endIndex);
if (folder.endsWith("poi")) {
continue;
}
Expand Down

0 comments on commit beca3a7

Please sign in to comment.