This is an automated email from the ASF dual-hosted git repository. svenmeier pushed a commit to branch WICKET-6321-cross-origin-integrity in repository https://gitbox.apache.org/repos/asf/wicket.git
commit 4eb9b40fcb9d4c5e79d20cbf5082b19cc223616f Author: Sven Meier <svenme...@apache.org> AuthorDate: Tue Dec 10 08:09:59 2019 +0100 WICKET-6667 script charset is deprecated remove constructors, charset can be set afterwards --- .../AbstractJavaScriptReferenceHeaderItem.java | 14 ------- .../apache/wicket/markup/head/CssHeaderItem.java | 9 ---- .../wicket/markup/head/JavaScriptHeaderItem.java | 49 ++-------------------- .../markup/head/JavaScriptReferenceHeaderItem.java | 6 +-- .../head/JavaScriptUrlReferenceHeaderItem.java | 5 +-- .../wicket/markup/head/ResourceAggregator.java | 5 +-- .../markup/html/internal/HeaderResponseTest.java | 6 +-- 7 files changed, 10 insertions(+), 84 deletions(-) diff --git a/wicket-core/src/main/java/org/apache/wicket/markup/head/AbstractJavaScriptReferenceHeaderItem.java b/wicket-core/src/main/java/org/apache/wicket/markup/head/AbstractJavaScriptReferenceHeaderItem.java index d91ac6f..18997ed 100644 --- a/wicket-core/src/main/java/org/apache/wicket/markup/head/AbstractJavaScriptReferenceHeaderItem.java +++ b/wicket-core/src/main/java/org/apache/wicket/markup/head/AbstractJavaScriptReferenceHeaderItem.java @@ -36,20 +36,6 @@ public abstract class AbstractJavaScriptReferenceHeaderItem extends JavaScriptHe private String integrity; /** - * Constructor. - * - * @param defer - * a flag indicating whether the execution of a script should be deferred (delayed) - * until after the page has been loaded. - * @param charset - * the charset to use when reading the script content - */ - protected AbstractJavaScriptReferenceHeaderItem(String charset) - { - this.charset = charset; - } - - /** * @return if the script should be loaded and executed asynchronously */ public boolean isAsync() diff --git a/wicket-core/src/main/java/org/apache/wicket/markup/head/CssHeaderItem.java b/wicket-core/src/main/java/org/apache/wicket/markup/head/CssHeaderItem.java index d79fe6b..24cf3e6 100644 --- a/wicket-core/src/main/java/org/apache/wicket/markup/head/CssHeaderItem.java +++ b/wicket-core/src/main/java/org/apache/wicket/markup/head/CssHeaderItem.java @@ -18,15 +18,8 @@ package org.apache.wicket.markup.head; import java.util.Objects; -import org.apache.wicket.core.util.string.CssUtils; -import org.apache.wicket.markup.html.CrossOrigin; -import org.apache.wicket.request.Response; import org.apache.wicket.request.mapper.parameter.PageParameters; import org.apache.wicket.request.resource.ResourceReference; -import org.apache.wicket.util.lang.Args; -import org.apache.wicket.util.value.AttributeMap; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; /** * Base class for all {@link HeaderItem}s that represent stylesheets. This class mainly contains @@ -38,8 +31,6 @@ public abstract class CssHeaderItem extends AbstractCspHeaderItem { private static final long serialVersionUID = 1L; - private static final Logger logger = LoggerFactory.getLogger(CssHeaderItem.class); - private String markupId; /** diff --git a/wicket-core/src/main/java/org/apache/wicket/markup/head/JavaScriptHeaderItem.java b/wicket-core/src/main/java/org/apache/wicket/markup/head/JavaScriptHeaderItem.java index a32e525..f4f99a5 100644 --- a/wicket-core/src/main/java/org/apache/wicket/markup/head/JavaScriptHeaderItem.java +++ b/wicket-core/src/main/java/org/apache/wicket/markup/head/JavaScriptHeaderItem.java @@ -18,12 +18,8 @@ package org.apache.wicket.markup.head; import java.util.Objects; -import org.apache.wicket.core.util.string.JavaScriptUtils; -import org.apache.wicket.request.Response; import org.apache.wicket.request.mapper.parameter.PageParameters; import org.apache.wicket.request.resource.ResourceReference; -import org.apache.wicket.util.lang.Args; -import org.apache.wicket.util.value.AttributeMap; /** * Base class for all {@link HeaderItem}s that represent javascripts. This class mainly contains @@ -76,7 +72,7 @@ public abstract class JavaScriptHeaderItem extends AbstractCspHeaderItem public static JavaScriptReferenceHeaderItem forReference(ResourceReference reference, PageParameters pageParameters, String id) { - return forReference(reference, pageParameters, id, null); + return new JavaScriptReferenceHeaderItem(reference, pageParameters, id); } /** @@ -92,7 +88,7 @@ public abstract class JavaScriptHeaderItem extends AbstractCspHeaderItem public static JavaScriptReferenceHeaderItem forReference(ResourceReference reference, String id) { - return forReference(reference, null, id, null); + return forReference(reference, null, id); } /** @@ -104,27 +100,7 @@ public abstract class JavaScriptHeaderItem extends AbstractCspHeaderItem */ public static JavaScriptReferenceHeaderItem forReference(ResourceReference reference) { - return forReference(reference, null, null, null); - } - - /** - * Creates a {@link JavaScriptReferenceHeaderItem} for the given reference. - * - * @param reference - * resource reference pointing to the javascript resource - * @param pageParameters - * the parameters for this Javascript resource reference - * @param id - * id that will be used to filter duplicate reference (it's still filtered by URL - * too) - * @param charset - * a non null value specifies the charset attribute of the script tag - * @return A newly created {@link JavaScriptReferenceHeaderItem} for the given reference. - */ - public static JavaScriptReferenceHeaderItem forReference(ResourceReference reference, - PageParameters pageParameters, String id, String charset) - { - return new JavaScriptReferenceHeaderItem(reference, pageParameters, id, charset); + return forReference(reference, null, null); } /** @@ -166,24 +142,7 @@ public abstract class JavaScriptHeaderItem extends AbstractCspHeaderItem */ public static JavaScriptUrlReferenceHeaderItem forUrl(String url, String id) { - return new JavaScriptUrlReferenceHeaderItem(url, id, null); - } - - /** - * Creates a {@link JavaScriptUrlReferenceHeaderItem} for the given url. - * - * @param url - * context-relative url of the the javascript resource - * @param id - * id that will be used to filter duplicate reference (it's still filtered by URL - * too) - * @param charset - * a non null value specifies the charset attribute of the script tag - * @return A newly created {@link JavaScriptUrlReferenceHeaderItem} for the given url. - */ - public static JavaScriptUrlReferenceHeaderItem forUrl(String url, String id, String charset) - { - return new JavaScriptUrlReferenceHeaderItem(url, id, charset); + return new JavaScriptUrlReferenceHeaderItem(url, id); } @Override diff --git a/wicket-core/src/main/java/org/apache/wicket/markup/head/JavaScriptReferenceHeaderItem.java b/wicket-core/src/main/java/org/apache/wicket/markup/head/JavaScriptReferenceHeaderItem.java index 0ca3851..3bebdf2 100644 --- a/wicket-core/src/main/java/org/apache/wicket/markup/head/JavaScriptReferenceHeaderItem.java +++ b/wicket-core/src/main/java/org/apache/wicket/markup/head/JavaScriptReferenceHeaderItem.java @@ -52,13 +52,9 @@ public class JavaScriptReferenceHeaderItem extends AbstractJavaScriptReferenceHe * @param id * id that will be used to filter duplicate reference (it's still filtered by URL * too) - * @param charset - * a non null value specifies the charset attribute of the script tag */ - public JavaScriptReferenceHeaderItem(ResourceReference reference, - PageParameters pageParameters, String id, String charset) + public JavaScriptReferenceHeaderItem(ResourceReference reference, PageParameters pageParameters, String id) { - super(charset); this.reference = Args.notNull(reference, "reference"); this.pageParameters = pageParameters; setId(id); diff --git a/wicket-core/src/main/java/org/apache/wicket/markup/head/JavaScriptUrlReferenceHeaderItem.java b/wicket-core/src/main/java/org/apache/wicket/markup/head/JavaScriptUrlReferenceHeaderItem.java index fff02b5..bcf7c7c 100644 --- a/wicket-core/src/main/java/org/apache/wicket/markup/head/JavaScriptUrlReferenceHeaderItem.java +++ b/wicket-core/src/main/java/org/apache/wicket/markup/head/JavaScriptUrlReferenceHeaderItem.java @@ -43,12 +43,9 @@ public class JavaScriptUrlReferenceHeaderItem extends AbstractJavaScriptReferenc * @param id * id that will be used to filter duplicate reference (it's still filtered by URL * too) - * @param charset - * a non null value specifies the charset attribute of the script tag */ - public JavaScriptUrlReferenceHeaderItem(String url, String id, String charset) + public JavaScriptUrlReferenceHeaderItem(String url, String id) { - super(charset); this.url = url; setId(id); } diff --git a/wicket-core/src/main/java/org/apache/wicket/markup/head/ResourceAggregator.java b/wicket-core/src/main/java/org/apache/wicket/markup/head/ResourceAggregator.java index 78526a1..659a0e7 100644 --- a/wicket-core/src/main/java/org/apache/wicket/markup/head/ResourceAggregator.java +++ b/wicket-core/src/main/java/org/apache/wicket/markup/head/ResourceAggregator.java @@ -511,9 +511,8 @@ public class ResourceAggregator extends DecoratingHeaderResponse { resultBundle = JavaScriptHeaderItem.forReference(bundleReference, item.getPageParameters(), - item.getId(), - item.getCharset() - ).setDefer(item.isDefer()).setAsync(item.isAsync()).setNonce(item.getNonce()); + item.getId() + ).setCharset(item.getCharset()).setDefer(item.isDefer()).setAsync(item.isAsync()).setNonce(item.getNonce()); } else { diff --git a/wicket-core/src/test/java/org/apache/wicket/markup/html/internal/HeaderResponseTest.java b/wicket-core/src/test/java/org/apache/wicket/markup/html/internal/HeaderResponseTest.java index 4767555..9d77c08 100644 --- a/wicket-core/src/test/java/org/apache/wicket/markup/html/internal/HeaderResponseTest.java +++ b/wicket-core/src/test/java/org/apache/wicket/markup/html/internal/HeaderResponseTest.java @@ -25,7 +25,6 @@ import java.nio.charset.Charset; import java.util.Optional; import org.apache.wicket.ThreadContext; -import org.apache.wicket.markup.head.CssHeaderItem; import org.apache.wicket.markup.head.IHeaderResponse; import org.apache.wicket.markup.head.JavaScriptHeaderItem; import org.apache.wicket.markup.head.internal.HeaderResponse; @@ -34,7 +33,6 @@ import org.apache.wicket.request.Request; import org.apache.wicket.request.Response; import org.apache.wicket.request.UrlRenderer; import org.apache.wicket.request.cycle.RequestCycle; -import org.apache.wicket.request.mapper.parameter.PageParameters; import org.apache.wicket.request.resource.IResource; import org.apache.wicket.request.resource.ResourceReference; import org.apache.wicket.response.StringResponse; @@ -146,7 +144,7 @@ class HeaderResponseTest void charsetSetJavaScriptReference() { String charset = "foo"; - headerResponse.render(JavaScriptHeaderItem.forUrl("js-resource.js", "some-id", charset)); + headerResponse.render(JavaScriptHeaderItem.forUrl("js-resource.js", "some-id").setCharset(charset)); String expected = "<script type=\"text/javascript\" id=\"some-id\" charset=\"" + charset + "\" src=\"" + RESOURCE_NAME + "\"></script>\n"; String actual = headerResponse.getResponse().toString(); @@ -161,7 +159,7 @@ class HeaderResponseTest @Test void charsetNotSetJavaScriptReference() { - headerResponse.render(JavaScriptHeaderItem.forUrl("js-resource.js", "some-id", null)); + headerResponse.render(JavaScriptHeaderItem.forUrl("js-resource.js", "some-id")); String expected = "<script type=\"text/javascript\" id=\"some-id\" src=\"" + RESOURCE_NAME + "\"></script>\n"; String actual = headerResponse.getResponse().toString();