mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-26 07:58:52 +01:00
use getInfo to run sanity check on .xwd files in download directory.
This prevents deliberately corrupted files from making it into dict lists. To the extent that checkSanity() works, it should make use of that dir safe.
This commit is contained in:
parent
9ff4596667
commit
b334e688bb
1 changed files with 8 additions and 6 deletions
|
@ -121,7 +121,7 @@ public class DictUtils {
|
|||
String[] list = dir.list();
|
||||
if ( null != list ) {
|
||||
for ( String file : list ) {
|
||||
if ( isDict( file, strict ) ) {
|
||||
if ( isDict( file, strict? dir : null ) ) {
|
||||
al.add( new DictAndLoc( removeDictExtn( file ), loc ) );
|
||||
}
|
||||
}
|
||||
|
@ -135,14 +135,14 @@ public class DictUtils {
|
|||
ArrayList<DictAndLoc> al = new ArrayList<DictAndLoc>();
|
||||
|
||||
for ( String file : getAssets( context ) ) {
|
||||
if ( isDict( file, false ) ) {
|
||||
if ( isDict( file, null ) ) {
|
||||
al.add( new DictAndLoc( removeDictExtn( file ),
|
||||
DictLoc.BUILT_IN ) );
|
||||
}
|
||||
}
|
||||
|
||||
for ( String file : context.fileList() ) {
|
||||
if ( isDict( file, false ) ) {
|
||||
if ( isDict( file, null ) ) {
|
||||
al.add( new DictAndLoc( removeDictExtn( file ),
|
||||
DictLoc.INTERNAL ) );
|
||||
}
|
||||
|
@ -464,11 +464,13 @@ public class DictUtils {
|
|||
return file.endsWith( XWConstants.GAME_EXTN );
|
||||
}
|
||||
|
||||
private static boolean isDict( String file, boolean strictTest )
|
||||
private static boolean isDict( String file, File dir )
|
||||
{
|
||||
boolean ok = file.endsWith( XWConstants.DICT_EXTN );
|
||||
if ( ok && strictTest ) {
|
||||
Utils.logf( "isDict: not really checking %s yet", file );
|
||||
if ( ok && null != dir ) {
|
||||
String fullPath = new File( dir, file ).getPath();
|
||||
ok = XwJNI.dict_getInfo( null, fullPath, JNIUtilsImpl.get(),
|
||||
true, null );
|
||||
}
|
||||
return ok;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue