Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,7 @@
import org.labkey.api.util.StringUtilsLabKey;
import org.labkey.api.util.SubstitutionFormat;
import org.labkey.api.util.TestContext;
import org.labkey.api.util.URIUtil;
import org.labkey.api.util.UnexpectedException;
import org.labkey.api.util.logging.LogHelper;
import org.labkey.api.view.ActionURL;
Expand Down Expand Up @@ -774,7 +775,17 @@ public ExpDataImpl createData(URI uri, XarSource source) throws XarFormatExcepti
{
path = FileUtil.stringToPath(source.getXarContext().getContainer(),
source.getCanonicalDataFileURL(FileUtil.pathToString(path)));
pathStr = FileUtil.relativizeUnix(source.getRootPath(), path, false);

// Only convert to a relative path if this is a descendant of the root:
path = path.normalize();
if (URIUtil.isDescendant(source.getRootPath().toUri(), path.toUri()))
Copy link

Copilot AI Dec 13, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Potential NullPointerException if source.getRootPath() returns null. Based on usage patterns in other parts of the codebase (e.g., XarReader.java line 924), getRootPath() can return null. Add a null check before calling toUri() on the result.

Suggested change
if (URIUtil.isDescendant(source.getRootPath().toUri(), path.toUri()))
if (source.getRootPath() != null && URIUtil.isDescendant(source.getRootPath().toUri(), path.toUri()))

Copilot uses AI. Check for mistakes.
{
pathStr = FileUtil.relativizeUnix(source.getRootPath(), path, false);
}
else
{
pathStr = FileUtil.pathToString(path);
}
}
catch (IOException e)
{
Expand Down
Loading