@@ -32,6 +32,8 @@ class ContentSecurityPolicyHeaderWriter implements HeaderWriter {
32
32
private static final String COLLECTION_INFO_PAGE_PATTERN =
33
33
Url .INFO_COLLECTION_PAGE .replace ("{slug}" , "" );
34
34
35
+ private static final String ADD_IMAGE_PAGE_PATTERN = "/series/(add|\\ d+|\\ d/(ask|image))" ;
36
+
35
37
private static final String TOGGLZ_PAGES_PATTERN = Url .TOGGLZ_CONSOLE_PAGE + '/' ;
36
38
37
39
// default policy prevents loading resources from any source
@@ -51,11 +53,12 @@ class ContentSecurityPolicyHeaderWriter implements HeaderWriter {
51
53
52
54
// - 'self' is required for our own CSS files
53
55
// - 'https://cdn.rawgit.com' is required by languages.min.css (TODO: GH #246)
56
+ private static final String STYLE_SRC = "style-src 'self' https://cdn.rawgit.com" ;
57
+
54
58
// - 'sha256-Dpm...' is required for 'box-shadow: none; border: 0px;' inline CSS
55
59
// that are using on /series/add and /series/{id} pages.
56
- private static final String STYLE_SRC =
57
- "style-src 'self' https://cdn.rawgit.com"
58
- + " 'sha256-DpmxvnMJIlwkpmmAANZYNzmyfnX2PQCBDO4CB2BFjzU='" ;
60
+ private static final String STYLE_SERIES_ADD_IMAGE =
61
+ " 'sha256-DpmxvnMJIlwkpmmAANZYNzmyfnX2PQCBDO4CB2BFjzU='" ;
59
62
60
63
// - 'https://www.gstatic.com' is required by Google Charts
61
64
// - 'sha256-/kX...' is required for 'overflow: hidden;' inline CSS for Google Charts.
@@ -118,6 +121,9 @@ private static String constructDirectives(HttpServletRequest request) {
118
121
if (onCollectionInfoPage ) {
119
122
sb .append (STYLE_COLLECTION_INFO );
120
123
124
+ } else if (uri .equals (Url .ADD_SERIES_PAGE ) || uri .matches (ADD_IMAGE_PAGE_PATTERN )) {
125
+ sb .append (STYLE_SERIES_ADD_IMAGE );
126
+
121
127
} else if (uri .startsWith (TOGGLZ_PAGES_PATTERN )) {
122
128
sb .append (STYLE_TOGGLZ );
123
129
}
0 commit comments