OSPRuntime.getDefaultSearchPaths() should not include ~ or FitBuilder.autoloadFits() should break early if xml files do not have `
The issue
Absent the preference autoload_search_paths, OSP includes the user home directory as a default search path.
Within the FitBuilder constructor, the function FitBuilder.autoloadFits() tries to read all .xml files in all search paths. This is problematic, especially if one has, say, a 1.6GB file of Arxiv.org metadata called ~/arxiv-meta.xml .
I think that ~ shouldn't be a search path in the first place. Either way, I think that in
osp/src/org/opensourcephysics/controls/XMLControlElement.java
the function readObject should contain a check. After :
|
private XMLControlElement readObject(XMLControlElement control, String xml) throws IOException { |
|
control.clearValues(); |
|
// set class name |
|
xml = xml.substring(xml.indexOf("class=")+7); //$NON-NLS-1$ |
|
String className = xml.substring(0, xml.indexOf("\"")); //$NON-NLS-1$ |
|
// workaround for media package name change |
|
int i = className.lastIndexOf("."); //$NON-NLS-1$ |
|
if(i>-1) { |
|
String packageName = className.substring(0, i); |
|
if(packageName.endsWith("org.opensourcephysics.media")) { //$NON-NLS-1$ |
|
className = packageName+".core"+className.substring(i); //$NON-NLS-1$ |
|
} |
|
} |
|
control.className = className; |
the function should assert packageName.startsWith("org.opensourcephysics").
OSPRuntime.getDefaultSearchPaths()should not include~orFitBuilder.autoloadFits()should break early if xml files do not have `The issue
Absent the preference
autoload_search_paths, OSP includes the user home directory as a default search path.Within the
FitBuilderconstructor, the functionFitBuilder.autoloadFits()tries to read all.xmlfiles in all search paths. This is problematic, especially if one has, say, a 1.6GB file of Arxiv.org metadata called~/arxiv-meta.xml.I think that
~shouldn't be a search path in the first place. Either way, I think that inosp/src/org/opensourcephysics/controls/XMLControlElement.javathe function
readObjectshould contain a check. After :osp/src/org/opensourcephysics/controls/XMLControlElement.java
Lines 1397 to 1410 in d809dbe
the function should assert
packageName.startsWith("org.opensourcephysics").