From c019c5d5ae61513aecb8b0f5a051e7b24b82db1d Mon Sep 17 00:00:00 2001 From: Tatu Lund Date: Tue, 24 Aug 2021 13:53:34 +0300 Subject: [PATCH] Update to Jsoup 1.14.2 (#12381) --- pom.xml | 2 +- .../java/com/vaadin/ui/declarative/Design.java | 2 +- .../tests/design/DeclarativeTestBaseBase.java | 18 ++++++++++++++++-- .../com/vaadin/tests/design/LocaleTest.java | 4 ++-- .../server/component/ReadEmptyDesignTest.java | 2 +- .../v7b1/BootstrapListenerCode.java | 2 +- 6 files changed, 22 insertions(+), 8 deletions(-) diff --git a/pom.xml b/pom.xml index 4e985f020f..fda31bfc68 100644 --- a/pom.xml +++ b/pom.xml @@ -31,7 +31,7 @@ 2.0.1.Final - 1.11.2 + 1.14.2 2.0 0.9.13 diff --git a/server/src/main/java/com/vaadin/ui/declarative/Design.java b/server/src/main/java/com/vaadin/ui/declarative/Design.java index 2e1e767f74..daed874a98 100644 --- a/server/src/main/java/com/vaadin/ui/declarative/Design.java +++ b/server/src/main/java/com/vaadin/ui/declarative/Design.java @@ -534,7 +534,7 @@ public class Design implements Serializable { private static Document createHtml(DesignContext designContext) { // Create the html tree skeleton. Document doc = new Document(""); - DocumentType docType = new DocumentType("html", "", "", ""); + DocumentType docType = new DocumentType("html", "", ""); doc.appendChild(docType); Element html = doc.createElement("html"); doc.appendChild(html); diff --git a/server/src/test/java/com/vaadin/tests/design/DeclarativeTestBaseBase.java b/server/src/test/java/com/vaadin/tests/design/DeclarativeTestBaseBase.java index 04c04ed76a..927e6b291c 100644 --- a/server/src/test/java/com/vaadin/tests/design/DeclarativeTestBaseBase.java +++ b/server/src/test/java/com/vaadin/tests/design/DeclarativeTestBaseBase.java @@ -6,6 +6,7 @@ import static org.junit.Assert.assertNull; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.util.ArrayList; +import java.util.Arrays; import java.util.Collection; import java.util.Collections; import java.util.HashSet; @@ -16,7 +17,6 @@ import java.util.logging.Logger; import org.jsoup.Jsoup; import org.jsoup.nodes.Attribute; -import org.jsoup.nodes.BooleanAttribute; import org.jsoup.nodes.Element; import org.jsoup.nodes.Node; import org.jsoup.nodes.TextNode; @@ -29,6 +29,13 @@ import com.vaadin.ui.declarative.DesignContext; import com.vaadin.ui.declarative.ShouldWriteDataDelegate; public abstract class DeclarativeTestBaseBase { + private static final String[] booleanAttributes = { "allowfullscreen", + "async", "autofocus", "checked", "compact", "declare", "default", + "defer", "disabled", "formnovalidate", "hidden", "inert", "ismap", + "itemscope", "multiple", "muted", "nohref", "noresize", "noshade", + "novalidate", "nowrap", "open", "readonly", "required", "reversed", + "seamless", "selected", "sortable", "truespeed", "typemustmatch" }; + private static final class AlwaysWriteDelegate implements ShouldWriteDataDelegate { private static final long serialVersionUID = -6345914431997793599L; @@ -249,7 +256,7 @@ public abstract class DeclarativeTestBaseBase { List names = new ArrayList<>(); for (Attribute a : producedElem.attributes().asList()) { names.add(a.getKey()); - if (a instanceof BooleanAttribute) { + if (isBooleanAttribute(a.getKey())) { booleanAttributes.add(a.getKey()); } } @@ -276,6 +283,13 @@ public abstract class DeclarativeTestBaseBase { return sb.toString(); } + /** + * Checks if this attribute name is defined as a boolean attribute in HTML5 + */ + protected static boolean isBooleanAttribute(final String key) { + return Arrays.binarySearch(booleanAttributes, key) >= 0; + } + protected String stripOptionTags(String design) { return design.replaceAll("[ \n]*[ \n]*", ""); diff --git a/server/src/test/java/com/vaadin/tests/design/LocaleTest.java b/server/src/test/java/com/vaadin/tests/design/LocaleTest.java index ab04cbc727..98eeb342bf 100644 --- a/server/src/test/java/com/vaadin/tests/design/LocaleTest.java +++ b/server/src/test/java/com/vaadin/tests/design/LocaleTest.java @@ -97,7 +97,7 @@ public class LocaleTest { private Document componentToDoc(DesignContext dc) { // Create the html tree skeleton. Document doc = new Document(""); - DocumentType docType = new DocumentType("html", "", "", ""); + DocumentType docType = new DocumentType("html", "", ""); doc.appendChild(docType); Element html = doc.createElement("html"); doc.appendChild(html); @@ -124,7 +124,7 @@ public class LocaleTest { public void testParsing() { // create an html document Document doc = new Document(""); - DocumentType docType = new DocumentType("html", "", "", ""); + DocumentType docType = new DocumentType("html", "", ""); doc.appendChild(docType); Element html = doc.createElement("html"); doc.appendChild(html); diff --git a/server/src/test/java/com/vaadin/tests/server/component/ReadEmptyDesignTest.java b/server/src/test/java/com/vaadin/tests/server/component/ReadEmptyDesignTest.java index 2757fd6c3d..58ba3131ef 100644 --- a/server/src/test/java/com/vaadin/tests/server/component/ReadEmptyDesignTest.java +++ b/server/src/test/java/com/vaadin/tests/server/component/ReadEmptyDesignTest.java @@ -59,7 +59,7 @@ public class ReadEmptyDesignTest { private Document createDesign() { Document doc = new Document(""); - DocumentType docType = new DocumentType("html", "", "", ""); + DocumentType docType = new DocumentType("html", "", ""); doc.appendChild(docType); Element html = doc.createElement("html"); doc.appendChild(html); diff --git a/uitest/src/main/java/com/vaadin/tests/minitutorials/v7b1/BootstrapListenerCode.java b/uitest/src/main/java/com/vaadin/tests/minitutorials/v7b1/BootstrapListenerCode.java index 56770d053e..0c3e884264 100644 --- a/uitest/src/main/java/com/vaadin/tests/minitutorials/v7b1/BootstrapListenerCode.java +++ b/uitest/src/main/java/com/vaadin/tests/minitutorials/v7b1/BootstrapListenerCode.java @@ -24,7 +24,7 @@ public class BootstrapListenerCode { @Override public void modifyBootstrapPage(BootstrapPageResponse response) { response.getDocument().body() - .appendChild(new Comment("Powered by Vaadin!", "")); + .appendChild(new Comment("Powered by Vaadin!")); response.setHeader("X-Powered-By", "Vaadin 7"); } -- 2.39.5