Skip to content

default search path contains ~ or FitBuilder.autoloadFits() should break early #4

@jcalbert

Description

@jcalbert

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").

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions