Added tolerance/warning for non-standard zips containing backslash paths
This commit is contained in:
parent
248cc5d6aa
commit
33064ebff2
4 changed files with 28 additions and 7 deletions
|
@ -5,6 +5,8 @@ Changelog
|
||||||
- Added a Validate warning for text files with LF line endings
|
- Added a Validate warning for text files with LF line endings
|
||||||
- Fixed data loss when decoding Windows-1252 text with accented characters
|
- Fixed data loss when decoding Windows-1252 text with accented characters
|
||||||
- Changed catalog auto-update url from GMM's repository to SMM's
|
- Changed catalog auto-update url from GMM's repository to SMM's
|
||||||
|
- Added tolerance for non-standard zips containing backslash paths
|
||||||
|
- Added a Validate warning for non-standard zips containing backslash paths
|
||||||
|
|
||||||
1.0:
|
1.0:
|
||||||
- Changed mod list to a table with checkboxes
|
- Changed mod list to a table with checkboxes
|
||||||
|
|
|
@ -414,6 +414,7 @@ public class FTLDat {
|
||||||
* The location it represents is not guaranteed to exist.
|
* The location it represents is not guaranteed to exist.
|
||||||
*/
|
*/
|
||||||
public File getFile( String innerPath ) {
|
public File getFile( String innerPath ) {
|
||||||
|
if ( innerPath.indexOf("\\") != -1 ) throw new IllegalArgumentException( "InnerPath contains backslashes: "+ innerPath );
|
||||||
return new File( rootDir, innerPath );
|
return new File( rootDir, innerPath );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -672,6 +673,7 @@ public class FTLDat {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void add( String innerPath, InputStream is ) throws IOException {
|
public void add( String innerPath, InputStream is ) throws IOException {
|
||||||
|
if ( innerPath.indexOf("\\") != -1 ) throw new IllegalArgumentException( "InnerPath contains backslashes: "+ innerPath );
|
||||||
if ( pathToIndexMap.containsKey( innerPath ) ) {
|
if ( pathToIndexMap.containsKey( innerPath ) ) {
|
||||||
throw new IOException( "InnerPath already exists: "+ innerPath );
|
throw new IOException( "InnerPath already exists: "+ innerPath );
|
||||||
}
|
}
|
||||||
|
@ -716,6 +718,7 @@ public class FTLDat {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void extractTo( String innerPath, OutputStream os ) throws FileNotFoundException, IOException {
|
public void extractTo( String innerPath, OutputStream os ) throws FileNotFoundException, IOException {
|
||||||
|
if ( innerPath.indexOf("\\") != -1 ) throw new IllegalArgumentException( "InnerPath contains backslashes: "+ innerPath );
|
||||||
if ( !pathToIndexMap.containsKey( innerPath ) ) {
|
if ( !pathToIndexMap.containsKey( innerPath ) ) {
|
||||||
throw new FileNotFoundException( "InnerPath does not exist: "+ innerPath );
|
throw new FileNotFoundException( "InnerPath does not exist: "+ innerPath );
|
||||||
}
|
}
|
||||||
|
@ -741,6 +744,7 @@ public class FTLDat {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void remove( String innerPath ) throws FileNotFoundException, IOException {
|
public void remove( String innerPath ) throws FileNotFoundException, IOException {
|
||||||
|
if ( innerPath.indexOf("\\") != -1 ) throw new IllegalArgumentException( "InnerPath contains backslashes: "+ innerPath );
|
||||||
if ( !pathToIndexMap.containsKey( innerPath ) ) {
|
if ( !pathToIndexMap.containsKey( innerPath ) ) {
|
||||||
throw new FileNotFoundException( "InnerPath does not exist: "+ innerPath );
|
throw new FileNotFoundException( "InnerPath does not exist: "+ innerPath );
|
||||||
}
|
}
|
||||||
|
@ -760,11 +764,13 @@ public class FTLDat {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean contains( String innerPath ) {
|
public boolean contains( String innerPath ) {
|
||||||
|
if ( innerPath.indexOf("\\") != -1 ) throw new IllegalArgumentException( "InnerPath contains backslashes: "+ innerPath );
|
||||||
return pathToIndexMap.containsKey( innerPath );
|
return pathToIndexMap.containsKey( innerPath );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public InputStream getInputStream( String innerPath ) throws FileNotFoundException, IOException {
|
public InputStream getInputStream( String innerPath ) throws FileNotFoundException, IOException {
|
||||||
|
if ( innerPath.indexOf("\\") != -1 ) throw new IllegalArgumentException( "InnerPath contains backslashes: "+ innerPath );
|
||||||
if ( !pathToIndexMap.containsKey( innerPath ) ) {
|
if ( !pathToIndexMap.containsKey( innerPath ) ) {
|
||||||
throw new FileNotFoundException( "InnerPath does not exist: "+ innerPath );
|
throw new FileNotFoundException( "InnerPath does not exist: "+ innerPath );
|
||||||
}
|
}
|
||||||
|
|
|
@ -190,9 +190,12 @@ public class ModPatchThread extends Thread {
|
||||||
while ( (item = zis.getNextEntry()) != null ) {
|
while ( (item = zis.getNextEntry()) != null ) {
|
||||||
if ( item.isDirectory() ) continue;
|
if ( item.isDirectory() ) continue;
|
||||||
|
|
||||||
Matcher m = pathPtn.matcher( item.getName() );
|
String innerPath = item.getName();
|
||||||
|
innerPath = innerPath.replace( '\\', '/' ); // Non-standard zips.
|
||||||
|
|
||||||
|
Matcher m = pathPtn.matcher( innerPath );
|
||||||
if ( !m.matches() ) {
|
if ( !m.matches() ) {
|
||||||
log.warn( String.format( "Unexpected innerPath: %s", item.getName() ) );
|
log.warn( String.format( "Unexpected innerPath: %s", innerPath ) );
|
||||||
zis.closeEntry();
|
zis.closeEntry();
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -203,13 +206,13 @@ public class ModPatchThread extends Thread {
|
||||||
|
|
||||||
AbstractPack ftlP = topFolderMap.get( topFolder );
|
AbstractPack ftlP = topFolderMap.get( topFolder );
|
||||||
if ( ftlP == null ) {
|
if ( ftlP == null ) {
|
||||||
log.warn( String.format( "Unexpected innerPath: %s", item.getName() ) );
|
log.warn( String.format( "Unexpected innerPath: %s", innerPath ) );
|
||||||
zis.closeEntry();
|
zis.closeEntry();
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( fileName.endsWith( ".xml.append" ) || fileName.endsWith( ".append.xml" ) ) {
|
if ( fileName.endsWith( ".xml.append" ) || fileName.endsWith( ".append.xml" ) ) {
|
||||||
String innerPath = parentPath + fileName.replaceAll( "[.](?:xml[.]append|append[.]xml)$", ".xml" );
|
innerPath = parentPath + fileName.replaceAll( "[.](?:xml[.]append|append[.]xml)$", ".xml" );
|
||||||
innerPath = checkCase( innerPath, knownPaths, knownPathsLower );
|
innerPath = checkCase( innerPath, knownPaths, knownPathsLower );
|
||||||
|
|
||||||
if ( !ftlP.contains( innerPath ) ) {
|
if ( !ftlP.contains( innerPath ) ) {
|
||||||
|
@ -234,7 +237,7 @@ public class ModPatchThread extends Thread {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if ( fileName.endsWith( ".xml" ) || fileName.endsWith( ".txt" ) ) {
|
else if ( fileName.endsWith( ".xml" ) || fileName.endsWith( ".txt" ) ) {
|
||||||
String innerPath = checkCase( item.getName(), knownPaths, knownPathsLower );
|
innerPath = checkCase( innerPath, knownPaths, knownPathsLower );
|
||||||
|
|
||||||
// Normalize line endings for other text files to CR-LF.
|
// Normalize line endings for other text files to CR-LF.
|
||||||
InputStream fixedStream = ModUtilities.setLineEndings( zis, "\r\n", modFile.getName()+":"+parentPath+fileName );
|
InputStream fixedStream = ModUtilities.setLineEndings( zis, "\r\n", modFile.getName()+":"+parentPath+fileName );
|
||||||
|
@ -249,7 +252,7 @@ public class ModPatchThread extends Thread {
|
||||||
ftlP.add( innerPath, fixedStream );
|
ftlP.add( innerPath, fixedStream );
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
String innerPath = checkCase( item.getName(), knownPaths, knownPathsLower );
|
innerPath = checkCase( innerPath, knownPaths, knownPathsLower );
|
||||||
|
|
||||||
if ( !moddedItems.contains(innerPath) )
|
if ( !moddedItems.contains(innerPath) )
|
||||||
moddedItems.add( innerPath );
|
moddedItems.add( innerPath );
|
||||||
|
|
|
@ -223,6 +223,15 @@ public class ModUtilities {
|
||||||
String innerPath = item.getName();
|
String innerPath = item.getName();
|
||||||
pendingMsgs.clear();
|
pendingMsgs.clear();
|
||||||
|
|
||||||
|
if ( innerPath.indexOf( "\\" ) != -1 ) {
|
||||||
|
pendingMsgs.add( new ReportMessage(
|
||||||
|
ReportMessage.ERROR,
|
||||||
|
String.format( "Backslashes in path. (Non-standard zip archive)" )
|
||||||
|
) );
|
||||||
|
modValid = false;
|
||||||
|
innerPath = innerPath.replace( '\\', '/' );
|
||||||
|
}
|
||||||
|
|
||||||
if ( !asciiEncoder.canEncode( innerPath ) ) {
|
if ( !asciiEncoder.canEncode( innerPath ) ) {
|
||||||
pendingMsgs.add( new ReportMessage(
|
pendingMsgs.add( new ReportMessage(
|
||||||
ReportMessage.ERROR,
|
ReportMessage.ERROR,
|
||||||
|
@ -379,9 +388,10 @@ public class ModUtilities {
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( !pendingMsgs.isEmpty() ) {
|
if ( !pendingMsgs.isEmpty() ) {
|
||||||
|
// Prepend the original path.
|
||||||
messages.add( new ReportMessage(
|
messages.add( new ReportMessage(
|
||||||
ReportMessage.SUBSECTION,
|
ReportMessage.SUBSECTION,
|
||||||
innerPath
|
item.getName()
|
||||||
) );
|
) );
|
||||||
messages.addAll( pendingMsgs );
|
messages.addAll( pendingMsgs );
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue