Skip to content
Merged
Show file tree
Hide file tree
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
27 changes: 25 additions & 2 deletions api/src/org/labkey/api/settings/AppPropsImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
import org.labkey.api.util.UsageReportingLevel;
import org.labkey.api.util.logging.LogHelper;
import org.labkey.api.view.ActionURL;
import org.labkey.filters.ContentSecurityPolicyFilter;

import java.io.File;
import java.io.IOException;
Expand Down Expand Up @@ -563,13 +564,35 @@ public String getXFrameOption()
return lookupStringValue(XFrameOption, "SAMEORIGIN");
}


private static final String not_init = "";
private String staticFilesPrefix = not_init;

@Override
public String getStaticFilesPrefix()
{
// CURRENTLY SET using -Dstatic.files.prefix=//static.web.site.com
// NOT IN UI, because one mistake will probably render the site unusable
String s = System.getProperty("static.files.prefix");
return trimToNull(s);
//noinspection StringEquality
if (not_init == staticFilesPrefix)
{
String s = trimToNull(System.getProperty("static.files.prefix"));
if (null != s)
{
try
{
var url = new URLHelper(s).setPath("");
if (StringUtils.isNotEmpty(url.getHost()))
ContentSecurityPolicyFilter.registerAllowedConnectionSource("static.files.prefix", url.toString());
staticFilesPrefix = s;
}
catch (URISyntaxException e)
{
staticFilesPrefix = null;
Copy link
Contributor

Choose a reason for hiding this comment

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

Won't this doom us to NPEs every time the method is called in the future? Some sort of logging about the bogus value would be useful too.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's fine. I cleverly made sure that this method is only called exactly once.

}
}
}
return staticFilesPrefix;
}

public static class SiteSettingsPropertyHandler extends StandardStartupPropertyHandler<SiteSettingsProperties>
Expand Down
1 change: 1 addition & 0 deletions core/src/org/labkey/core/webdav/DavController.java
Original file line number Diff line number Diff line change
Expand Up @@ -5036,6 +5036,7 @@ private WebdavStatus serveResource(WebdavResource resource, boolean content)
getResponse().setPublicStatic(alwaysCache ? 365 : 35);
}
}
getResponse().setHeader("Access-Control-Allow-Origin", "*");
}
else
{
Expand Down