diff options
author | Artur <artur@vaadin.com> | 2017-03-09 14:50:46 +0200 |
---|---|---|
committer | Henri Sara <henri.sara@gmail.com> | 2017-03-30 11:20:55 +0300 |
commit | f91410e04b99a7f31b5107aa91bbd029606cc921 (patch) | |
tree | a61dd077c9e183b8d6f35e323a97807383ace115 /server | |
parent | a6a456b02461e382b32c408d6241bbb9fb35bd85 (diff) | |
download | vaadin-framework-f91410e04b99a7f31b5107aa91bbd029606cc921.tar.gz vaadin-framework-f91410e04b99a7f31b5107aa91bbd029606cc921.zip |
Include charset in text/html responses (#8777)
Fixes #8775
Diffstat (limited to 'server')
4 files changed, 11 insertions, 6 deletions
diff --git a/server/src/main/java/com/vaadin/server/BootstrapHandler.java b/server/src/main/java/com/vaadin/server/BootstrapHandler.java index 81ffb2fe23..218ed394cb 100644 --- a/server/src/main/java/com/vaadin/server/BootstrapHandler.java +++ b/server/src/main/java/com/vaadin/server/BootstrapHandler.java @@ -363,7 +363,8 @@ public abstract class BootstrapHandler extends SynchronizedRequestHandler { private void writeBootstrapPage(VaadinResponse response, String html) throws IOException { - response.setContentType("text/html"); + response.setContentType( + ApplicationConstants.CONTENT_TYPE_TEXT_HTML_UTF_8); try (BufferedWriter writer = new BufferedWriter( new OutputStreamWriter(response.getOutputStream(), "UTF-8"))) { writer.append(html); @@ -383,8 +384,8 @@ public abstract class BootstrapHandler extends SynchronizedRequestHandler { document.child(0).before(doctype); Element head = document.head(); - head.appendElement("meta").attr("http-equiv", "Content-Type") - .attr("content", "text/html; charset=utf-8"); + head.appendElement("meta").attr("http-equiv", "Content-Type").attr( + "content", ApplicationConstants.CONTENT_TYPE_TEXT_HTML_UTF_8); /* * Enable Chrome Frame in all versions of IE if installed. diff --git a/server/src/main/java/com/vaadin/server/VaadinServlet.java b/server/src/main/java/com/vaadin/server/VaadinServlet.java index e9c302f7a4..2c6c55f465 100644 --- a/server/src/main/java/com/vaadin/server/VaadinServlet.java +++ b/server/src/main/java/com/vaadin/server/VaadinServlet.java @@ -55,6 +55,7 @@ import com.vaadin.annotations.VaadinServletConfiguration; import com.vaadin.annotations.VaadinServletConfiguration.InitParameterName; import com.vaadin.sass.internal.ScssStylesheet; import com.vaadin.server.communication.ServletUIInitHandler; +import com.vaadin.shared.ApplicationConstants; import com.vaadin.shared.JsonConstants; import com.vaadin.shared.Version; import com.vaadin.ui.UI; @@ -585,7 +586,7 @@ public class VaadinServlet extends HttpServlet implements Constants { output += "</a>"; } getService().writeStringResponse(response, - "text/html; charset=UTF-8", output); + ApplicationConstants.CONTENT_TYPE_TEXT_HTML_UTF_8, output); } } diff --git a/server/src/main/java/com/vaadin/server/communication/FileUploadHandler.java b/server/src/main/java/com/vaadin/server/communication/FileUploadHandler.java index 4e0c41bbcb..3a0f8f7d79 100644 --- a/server/src/main/java/com/vaadin/server/communication/FileUploadHandler.java +++ b/server/src/main/java/com/vaadin/server/communication/FileUploadHandler.java @@ -36,6 +36,7 @@ import com.vaadin.server.UploadException; import com.vaadin.server.VaadinRequest; import com.vaadin.server.VaadinResponse; import com.vaadin.server.VaadinSession; +import com.vaadin.shared.ApplicationConstants; import com.vaadin.ui.UI; import com.vaadin.ui.Upload.FailedEvent; @@ -675,7 +676,8 @@ public class FileUploadHandler implements RequestHandler { */ protected void sendUploadResponse(VaadinRequest request, VaadinResponse response) throws IOException { - response.setContentType("text/html"); + response.setContentType( + ApplicationConstants.CONTENT_TYPE_TEXT_HTML_UTF_8); try (OutputStream out = response.getOutputStream()) { final PrintWriter outWriter = new PrintWriter( new BufferedWriter(new OutputStreamWriter(out, "UTF-8"))); diff --git a/server/src/main/java/com/vaadin/ui/LoginForm.java b/server/src/main/java/com/vaadin/ui/LoginForm.java index 400a9826fa..01f64665bd 100644 --- a/server/src/main/java/com/vaadin/ui/LoginForm.java +++ b/server/src/main/java/com/vaadin/ui/LoginForm.java @@ -25,6 +25,7 @@ import java.util.HashMap; import java.util.Map; import com.vaadin.server.StreamResource; +import com.vaadin.shared.ApplicationConstants; import com.vaadin.shared.Registration; import com.vaadin.shared.ui.loginform.LoginFormConstants; import com.vaadin.shared.ui.loginform.LoginFormRpc; @@ -307,7 +308,7 @@ public class LoginForm extends AbstractSingleComponentContainer { StreamResource resource = new StreamResource(new LoginStreamSource(), LoginFormConstants.LOGIN_RESOURCE_NAME); - resource.setMIMEType("text/html; charset=utf-8"); + resource.setMIMEType(ApplicationConstants.CONTENT_TYPE_TEXT_HTML_UTF_8); resource.setCacheTime(-1); setResource(LoginFormConstants.LOGIN_RESOURCE_NAME, resource); |