Workaround for snapshot files with not-to-spec slashes.

This commit is contained in:
wizjany 2020-08-30 12:11:34 -04:00
parent 8e53aa0891
commit beca3a707d
2 changed files with 17 additions and 6 deletions

View File

@ -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;
}

View File

@ -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;
}