solomax commented on a change in pull request #376: WICKET-6682 add CSP nonce 
support: DecoratingHeaderResponse approach
URL: https://github.com/apache/wicket/pull/376#discussion_r303282678
 
 

 ##########
 File path: 
wicket-core/src/main/java/org/apache/wicket/core/util/string/CssUtils.java
 ##########
 @@ -119,27 +156,33 @@ public static void writeLinkUrl(final Response response, 
final CharSequence url,
        public static void writeLinkUrl(final Response response, final 
CharSequence url,
                final CharSequence media, final String markupId, final String 
rel)
        {
-               response.write("<link rel=\"stylesheet\" type=\"text/css\" 
href=\"");
-               response.write(Strings.escapeMarkup(url));
-               response.write("\"");
+               AttributeMap attributes = new AttributeMap();
+               attributes.add(HeaderItemAttribute.LINK_REL, 
Strings.isEmpty(rel) ? "stylesheet" : rel);
+               attributes.add(HeaderItemAttribute.TYPE, "text/css");
+               attributes.add(HeaderItemAttribute.LINK_HREF, 
String.valueOf(url));
                if (Strings.isEmpty(media) == false)
                {
-                       response.write(" media=\"");
-                       response.write(Strings.escapeMarkup(media));
-                       response.write("\"");
+                       attributes.add(HeaderItemAttribute.LINK_MEDIA, 
media.toString());
                }
                if (Strings.isEmpty(markupId) == false)
                {
-                       response.write(" id=\"");
-                       response.write(Strings.escapeMarkup(markupId));
-                       response.write("\"");
-               }
-               if (Strings.isEmpty(rel) == false)
-               {
-                       response.write(" rel=\"");
-                       response.write(Strings.escapeMarkup(rel));
-                       response.write("\"");
+                       attributes.add(HeaderItemAttribute.ID, markupId);
                }
+               writeLinkUrl(response, attributes);
+       }
+
+       /**
+        * Writes a reference to a css file in the response object
+        *
+        * @param response
+        *              the response to write to
+        * @param attributes
+        *              Attributes map
+        */
+       public static void writeLinkUrl(final Response response, IValueMap 
attributes)
 
 Review comment:
   `writeLinkAttributes`?

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to