-
Notifications
You must be signed in to change notification settings - Fork 31
Description
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 :
osp/src/org/opensourcephysics/controls/XMLControlElement.java
Lines 1397 to 1410 in d809dbe
| 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").