Skip to content

Commit

Permalink
Don't try to open files you are not supposed to.
Browse files Browse the repository at this point in the history
  • Loading branch information
Mailaender committed Feb 24, 2022
1 parent 9c0d6ba commit cb161a9
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ public class ChromatogramMagicNumberMatcher extends AbstractMagicNumberMatcher i
public boolean checkFileFormat(File file) {

boolean isValidFormat = false;
if(file.isDirectory() || !checkFileExtension(file, ".animl")) {
return isValidFormat;
}
try {
if(!checkFileExtension(file, ".animl")) {
return isValidFormat;
}
DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder();
Document document = documentBuilder.parse(file);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ public class MassSpectrumMagicNumberMatcher extends AbstractMagicNumberMatcher i
public boolean checkFileFormat(File file) {

boolean isValidFormat = false;
if(file.isDirectory() || !checkFileExtension(file, ".animl")) {
return isValidFormat;
}
try {
if(!checkFileExtension(file, ".animl")) {
return isValidFormat;
}
DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder();
Document document = documentBuilder.parse(file);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,9 @@ public class ChromatogramReader extends AbstractChromatogramMSDReader {
@Override
public IChromatogramMSD read(File file, IProgressMonitor monitor) throws IOException {

if(file.isDirectory() || !file.getName().endsWith(".animl")) {
return null;
}
IVendorChromatogram chromatogram = null;
try {
AnIMLType animl = XmlReader.getAnIML(file);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ public class MassSpectrumReader extends AbstractMassSpectraReader implements IMa
@Override
public IMassSpectra read(File file, IProgressMonitor monitor) throws IOException {

if(file.isDirectory() || !file.getName().endsWith(".animl")) {
return null;
}
IVendorStandaloneMassSpectrum massSpectrum = null;
//
try {
Expand Down

0 comments on commit cb161a9

Please sign in to comment.