]> source.dussan.org Git - vaadin-framework.git/commitdiff
#7032 LoginForm should explicitly define utf-8 charset in getLoginHTML() method
authorLeif Åstrand <leif@vaadin.com>
Mon, 22 Aug 2011 14:51:51 +0000 (14:51 +0000)
committerLeif Åstrand <leif@vaadin.com>
Mon, 22 Aug 2011 14:51:51 +0000 (14:51 +0000)
svn changeset:20546/svn branch:6.7

src/com/vaadin/ui/LoginForm.java

index 6c1edb817159c07bc3e7cfe8ebfdc63a24d2db94..509a072c275ef66b374d0d3886bcaff76444c8c5 100644 (file)
@@ -5,6 +5,7 @@ package com.vaadin.ui;
 
 import java.io.ByteArrayInputStream;
 import java.io.Serializable;
+import java.io.UnsupportedEncodingException;
 import java.lang.reflect.Method;
 import java.net.URL;
 import java.util.HashMap;
@@ -136,48 +137,53 @@ public class LoginForm extends CustomComponent {
         String appUri = getApplication().getURL().toString()
                 + getWindow().getName() + "/";
 
-        return ("<!DOCTYPE html PUBLIC \"-//W3C//DTD "
-                + "XHTML 1.0 Transitional//EN\" "
-                + "\"http://www.w3.org/TR/xhtml1/"
-                + "DTD/xhtml1-transitional.dtd\">\n" + "<html>"
-                + "<head><script type='text/javascript'>"
-                + "var setTarget = function() {" + "var uri = '"
-                + appUri
-                + "loginHandler"
-                + "'; var f = document.getElementById('loginf');"
-                + "document.forms[0].action = uri;document.forms[0].username.focus();};"
-                + ""
-                + "var styles = window.parent.document.styleSheets;"
-                + "for(var j = 0; j < styles.length; j++) {\n"
-                + "if(styles[j].href) {"
-                + "var stylesheet = document.createElement('link');\n"
-                + "stylesheet.setAttribute('rel', 'stylesheet');\n"
-                + "stylesheet.setAttribute('type', 'text/css');\n"
-                + "stylesheet.setAttribute('href', styles[j].href);\n"
-                + "document.getElementsByTagName('head')[0].appendChild(stylesheet);\n"
-                + "}"
-                + "}\n"
-                + "function submitOnEnter(e) { var keycode = e.keyCode || e.which;"
-                + " if (keycode == 13) {document.forms[0].submit();}  } \n"
-                + "</script>"
-                + "</head><body onload='setTarget();' style='margin:0;padding:0; background:transparent;' class=\""
-                + ApplicationConnection.GENERATED_BODY_CLASSNAME
-                + "\">"
-                + "<div class='v-app v-app-loginpage' style=\"background:transparent;\">"
-                + "<iframe name='logintarget' style='width:0;height:0;"
-                + "border:0;margin:0;padding:0;'></iframe>"
-                + "<form id='loginf' target='logintarget' onkeypress=\"submitOnEnter(event)\" method=\"post\">"
-                + "<div>"
-                + usernameCaption
-                + "</div><div >"
-                + "<input class='v-textfield' style='display:block;' type='text' name='username'></div>"
-                + "<div>"
-                + passwordCaption
-                + "</div>"
-                + "<div><input class='v-textfield' style='display:block;' type='password' name='password'></div>"
-                + "<div><div onclick=\"document.forms[0].submit();\" tabindex=\"0\" class=\"v-button\" role=\"button\" ><span class=\"v-button-wrap\"><span class=\"v-button-caption\">"
-                + loginButtonCaption + "</span></span></div></div></form></div>" + "</body></html>")
-                .getBytes();
+        try {
+            return ("<!DOCTYPE html PUBLIC \"-//W3C//DTD "
+                    + "XHTML 1.0 Transitional//EN\" "
+                    + "\"http://www.w3.org/TR/xhtml1/"
+                    + "DTD/xhtml1-transitional.dtd\">\n" + "<html>"
+                    + "<head><script type='text/javascript'>"
+                    + "var setTarget = function() {" + "var uri = '"
+                    + appUri
+                    + "loginHandler"
+                    + "'; var f = document.getElementById('loginf');"
+                    + "document.forms[0].action = uri;document.forms[0].username.focus();};"
+                    + ""
+                    + "var styles = window.parent.document.styleSheets;"
+                    + "for(var j = 0; j < styles.length; j++) {\n"
+                    + "if(styles[j].href) {"
+                    + "var stylesheet = document.createElement('link');\n"
+                    + "stylesheet.setAttribute('rel', 'stylesheet');\n"
+                    + "stylesheet.setAttribute('type', 'text/css');\n"
+                    + "stylesheet.setAttribute('href', styles[j].href);\n"
+                    + "document.getElementsByTagName('head')[0].appendChild(stylesheet);\n"
+                    + "}"
+                    + "}\n"
+                    + "function submitOnEnter(e) { var keycode = e.keyCode || e.which;"
+                    + " if (keycode == 13) {document.forms[0].submit();}  } \n"
+                    + "</script>"
+                    + "</head><body onload='setTarget();' style='margin:0;padding:0; background:transparent;' class=\""
+                    + ApplicationConnection.GENERATED_BODY_CLASSNAME
+                    + "\">"
+                    + "<div class='v-app v-app-loginpage' style=\"background:transparent;\">"
+                    + "<iframe name='logintarget' style='width:0;height:0;"
+                    + "border:0;margin:0;padding:0;'></iframe>"
+                    + "<form id='loginf' target='logintarget' onkeypress=\"submitOnEnter(event)\" method=\"post\">"
+                    + "<div>"
+                    + usernameCaption
+                    + "</div><div >"
+                    + "<input class='v-textfield' style='display:block;' type='text' name='username'></div>"
+                    + "<div>"
+                    + passwordCaption
+                    + "</div>"
+                    + "<div><input class='v-textfield' style='display:block;' type='password' name='password'></div>"
+                    + "<div><div onclick=\"document.forms[0].submit();\" tabindex=\"0\" class=\"v-button\" role=\"button\" ><span class=\"v-button-wrap\"><span class=\"v-button-caption\">"
+                    + loginButtonCaption
+                    + "</span></span></div></div></form></div>" + "</body></html>")
+                    .getBytes("UTF-8");
+        } catch (UnsupportedEncodingException e) {
+            throw new RuntimeException("UTF-8 encoding not avalable", e);
+        }
     }
 
     @Override