@@ -54,9 +54,16 @@ class ContentSecurityPolicyHeaderWriter implements HeaderWriter {
54
54
// CheckStyle: ignore LineLength for next 1 line
55
55
private static final String REPORT_URI = "report-uri https://mystamps.report-uri.io/r/default/csp/reportOnly" ;
56
56
57
- // - 'self' is required for our own CSS files
58
57
// - 'https://cdn.rawgit.com' is required by languages.min.css (TODO: GH #246)
59
- private static final String STYLE_SRC = "style-src 'self' https://cdn.rawgit.com" ;
58
+ private static final String STYLE_SRC = "style-src https://cdn.rawgit.com" ;
59
+
60
+ // - 'self' is required for our own CSS files
61
+ private static final String STYLES_SELF = " 'self'" ;
62
+
63
+ // - 'https://stamps.filezz.ru' is required for our own CSS files
64
+ // - 'https://maxcdn.bootstrapcdn.com' is required for bootstrap.min.js
65
+ private static final String STYLES_CDN =
66
+ " https://stamps.filezz.ru https://maxcdn.bootstrapcdn.com" ;
60
67
61
68
// - 'sha256-Dpm...' is required for 'box-shadow: none; border: 0px;' inline CSS
62
69
// that are using on /series/add and /series/{id} pages.
@@ -118,6 +125,7 @@ public void writeHeaders(HttpServletRequest request, HttpServletResponse respons
118
125
response .setHeader ("Content-Security-Policy-Report-Only" , constructDirectives (uri ));
119
126
}
120
127
128
+ @ SuppressWarnings ("PMD.NPathComplexity" )
121
129
private String constructDirectives (String uri ) {
122
130
boolean onCollectionInfoPage = uri .startsWith (COLLECTION_INFO_PAGE_PATTERN );
123
131
@@ -127,7 +135,8 @@ private String constructDirectives(String uri) {
127
135
.append (IMG_SRC ).append (SEPARATOR )
128
136
.append (FONT_SRC ).append (SEPARATOR )
129
137
.append (REPORT_URI ).append (SEPARATOR )
130
- .append (STYLE_SRC );
138
+ .append (STYLE_SRC )
139
+ .append (useSingleHost ? STYLES_SELF : STYLES_CDN );
131
140
132
141
if (onCollectionInfoPage ) {
133
142
sb .append (STYLE_COLLECTION_INFO );
0 commit comments