@@ -53,7 +53,6 @@ public class ContentSecurityPolicyFilter implements Filter
5353 private static final Logger LOG = LogHelper .getLogger (ContentSecurityPolicyFilter .class , "Register/unregister allowed resource hosts" );
5454
5555 private static final String NONCE_SUBST = "REQUEST.SCRIPT.NONCE" ;
56- private static final String REPORT_PARAMETER_SUBSTITUTION = "CSP.REPORT.PARAMS" ;
5756 private static final String UPGRADE_INSECURE_REQUESTS_SUBSTITUTION = "UPGRADE.INSECURE.REQUESTS" ;
5857 private static final String HEADER_NONCE = "org.labkey.filters.ContentSecurityPolicyFilter#NONCE" ; // needs to match PageConfig.HEADER_NONCE
5958
@@ -120,14 +119,8 @@ public void init(FilterConfig filterConfig) throws ServletException
120119 String paramValue = filterConfig .getInitParameter (paramName );
121120 if ("policy" .equalsIgnoreCase (paramName ))
122121 {
123- String s = filterPolicy (paramValue );
124-
125- // Replace REPORT_PARAMETER_SUBSTITUTION now since its value is static
126- s = substituteReportParams (s );
127-
128- _stashedTemplate = s ;
129-
130- extractCspVersion (s );
122+ _stashedTemplate = filterPolicy (paramValue );
123+ extractCspVersion (_stashedTemplate );
131124 }
132125 else if ("disposition" .equalsIgnoreCase (paramName ))
133126 {
@@ -150,12 +143,6 @@ else if ("disposition".equalsIgnoreCase(paramName))
150143 _reportToEndpointName = "csp-" + getType ().name ().toLowerCase ();
151144 }
152145
153- private String substituteReportParams (String expression )
154- {
155- return StringExpressionFactory .create (expression , false , NullValueBehavior .KeepSubstitution )
156- .eval (Map .of (REPORT_PARAMETER_SUBSTITUTION , "labkeyVersion=" + PageFlowUtil .encodeURIComponent (AppProps .getInstance ().getReleaseVersion ())));
157- }
158-
159146 /** Filter out block comments and replace special characters in the provided policy */
160147 public static String filterPolicy (String policy )
161148 {
@@ -292,7 +279,7 @@ private CspFilterSettings(ContentSecurityPolicyFilter filter, String baseServerU
292279 @ SuppressWarnings ("DataFlowIssue" )
293280 ActionURL violationUrl = PageFlowUtil .urlProvider (AdminUrls .class ).getCspReportToURL (filter .getCspVersion ());
294281 // Use an absolute URL so we always post to https:, even if the violating request uses http:
295- _reportingEndpointsHeaderValue = filter .getReportToEndpointName () + "=\" " + filter . substituteReportParams ( violationUrl .getURIString () + "&${CSP.REPORT.PARAMS}" ) + "\" " ;
282+ _reportingEndpointsHeaderValue = filter .getReportToEndpointName () + "=\" " + violationUrl .getURIString () + "\" " ;
296283
297284 // Add "report-to" directive to the policy
298285 _policyTemplate = filter .getStashedTemplate () + " report-to " + filter .getReportToEndpointName () + " ;" ;
@@ -305,15 +292,15 @@ private CspFilterSettings(ContentSecurityPolicyFilter filter, String baseServerU
305292
306293 _previousBaseServerUrl = baseServerUrl ;
307294
308- final String allowSubstitutedPolicy ;
295+ final String substitutedPolicy ;
309296
310297 synchronized (SUBSTITUTION_LOCK )
311298 {
312- allowSubstitutedPolicy = StringExpressionFactory .create (_policyTemplate , false , NullValueBehavior .KeepSubstitution )
299+ substitutedPolicy = StringExpressionFactory .create (_policyTemplate , false , NullValueBehavior .KeepSubstitution )
313300 .eval (SUBSTITUTION_MAP );
314301 }
315302
316- _policyExpression = StringExpressionFactory .create (allowSubstitutedPolicy , false , NullValueBehavior .ReplaceNullAndMissingWithBlank );
303+ _policyExpression = StringExpressionFactory .create (substitutedPolicy , false , NullValueBehavior .ReplaceNullAndMissingWithBlank );
317304 }
318305
319306 public String getPolicyTemplate ()
0 commit comments