From: Artur Signell Date: Wed, 24 Aug 2016 11:03:42 +0000 (+0300) Subject: Properly encode special UTF-8 characters (#19928) X-Git-Tag: 7.7.1~23 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=11c3f8bd9ea65f7a7b8da9a282c31a127bd475a6;p=vaadin-framework.git Properly encode special UTF-8 characters (#19928) The main encoding problem was fixed in GWT 2.7.0.vaadin4. Vaadin 8 is already fixed as it uses GWT 2.8 Change-Id: I78ea30c1ff81d44432cd82ecd23eda8eb86e6efb --- diff --git a/build.properties b/build.properties index 2148fc00e6..846e069898 100644 --- a/build.properties +++ b/build.properties @@ -6,5 +6,5 @@ vaadin.url=http://vaadin.com vaadin.java.version=1.6 vaadin.version=7.7.0-SNAPSHOT vaadin.sass.version=0.9.13 -gwt.version=2.7.0.vaadin3 +gwt.version=2.7.0.vaadin4 commons-io.version=2.4 diff --git a/pom.xml b/pom.xml index 5f5eac095d..6f1d59a2ee 100644 --- a/pom.xml +++ b/pom.xml @@ -29,7 +29,7 @@ 6.0.2 0.9.13 - 2.7.0.vaadin3 + 2.7.0.vaadin4 7.7.0.alpha1 2.0 diff --git a/uitest/src/main/java/com/vaadin/tests/core/SpecialCharactersEncodingUI.java b/uitest/src/main/java/com/vaadin/tests/core/SpecialCharactersEncodingUI.java new file mode 100644 index 0000000000..9dc3351083 --- /dev/null +++ b/uitest/src/main/java/com/vaadin/tests/core/SpecialCharactersEncodingUI.java @@ -0,0 +1,32 @@ +package com.vaadin.tests.core; + +import com.vaadin.server.VaadinRequest; +import com.vaadin.tests.components.AbstractTestUI; +import com.vaadin.ui.ComboBox; +import com.vaadin.ui.Label; +import com.vaadin.ui.MenuBar; +import com.vaadin.ui.MenuBar.MenuItem; +import com.vaadin.ui.TextField; + +public class SpecialCharactersEncodingUI extends AbstractTestUI { + + public static String textWithZwnj = "\ufeffछुट्‌याउनेछन् क्ष क्‌ष क्‍ष"; + + @Override + protected void setup(VaadinRequest request) { + MenuBar menubar = new MenuBar(); + menubar.setId("menubar"); + addComponent(menubar); + menubar.addItem(textWithZwnj, null); + + Label label = new Label(textWithZwnj); + label.setId("label"); + addComponent(label); + + TextField f = new TextField("Textfield", textWithZwnj); + f.setId("textfield"); + addComponent(f); + + } + +} diff --git a/uitest/src/test/java/com/vaadin/tests/core/SpecialCharactersEncodingUITest.java b/uitest/src/test/java/com/vaadin/tests/core/SpecialCharactersEncodingUITest.java new file mode 100644 index 0000000000..f92e6cbcf5 --- /dev/null +++ b/uitest/src/test/java/com/vaadin/tests/core/SpecialCharactersEncodingUITest.java @@ -0,0 +1,44 @@ +package com.vaadin.tests.core; + +import java.util.Collections; +import java.util.List; + +import org.junit.Assert; +import org.junit.Test; +import org.openqa.selenium.WebElement; +import org.openqa.selenium.remote.DesiredCapabilities; + +import com.vaadin.testbench.By; +import com.vaadin.testbench.elements.LabelElement; +import com.vaadin.testbench.elements.MenuBarElement; +import com.vaadin.testbench.elements.TextFieldElement; +import com.vaadin.testbench.parallel.Browser; +import com.vaadin.tests.tb3.MultiBrowserTest; +import com.vaadin.tests.tb3.SingleBrowserTest; +import com.vaadin.tests.tb3.SingleBrowserTestPhantomJS2; + +public class SpecialCharactersEncodingUITest extends SingleBrowserTest { + + @Test + public void checkEncoding() { + openTestURL(); + String textFieldValue = $(TextFieldElement.class).id("textfield") + .getValue(); + Assert.assertEquals(SpecialCharactersEncodingUI.textWithZwnj, + textFieldValue); + LabelElement label = $(LabelElement.class).id("label"); + String labelValue = getHtml(label); // getText() strips some characters + Assert.assertEquals(SpecialCharactersEncodingUI.textWithZwnj, + labelValue); + + MenuBarElement menubar = $(MenuBarElement.class).first(); + WebElement menuItem = menubar + .findElement(By.className("v-menubar-menuitem-caption")); + Assert.assertEquals(SpecialCharactersEncodingUI.textWithZwnj, + getHtml(menuItem)); + } + + private String getHtml(WebElement element) { + return element.getAttribute("innerHTML"); + } +}