The following change is made to support non-ascii characters in the
URL. The change is: encode the part of the URL before the query string
in UTF-8. The URL will have double-hex-encoded characters, which is
supported by the browsers all-right. As UTF-8 is compatible with ASCII
(first 128 UTF-8 characters are the same as the ASCII code page), this
change won't affect any of the current JSF users. The TestHtmlUtils
test case proves this point as well. The test itself passes with no changes, 
though it is updated as well to test the UTF-8 support. See below the 
SVN diff for the 2 files changed (HtmlUtils, and the accrodgin test).


SECTION: Changes

M src/main/java/com/sun/faces/util/HtmlUtils.java
 - writeUrl() methods updated to use utf-8 encoding for the 
   part of the URL before the query (before "?")

M test/com/sun/faces/util/TestHtmlUtils.java
 - testWriteUrl() updated and new test point is added to test
   to cover the UTF-8 encoding in the URL; previous tests are
   kept unchanged.


SECTION: Diffs

Index: src/main/java/com/sun/faces/util/HtmlUtils.java
===================================================================
--- src/main/java/com/sun/faces/util/HtmlUtils.java	(revision 8390)
+++ src/main/java/com/sun/faces/util/HtmlUtils.java	(working copy)
@@ -649,6 +649,7 @@
                                 String queryEncoding)
           throws IOException, UnsupportedEncodingException {
 
+        char[] charArray = new char[1];
         int length = text.length();
         if (length >= 16) {
             text.getChars(0, length, textBuff, 0);
@@ -661,10 +662,8 @@
                     if (ch == ' ') {
                         out.write('+');
                     } else {
-                        // ISO-8859-1.  Blindly assume the character will be < 255.
-                        // Not much we can do if it isn't.
-                        writeURIDoubleHex(out, ch);
-
+                        charArray[0] = ch;
+                        encodeURIString(out, charArray, "utf-8", 0, 1);
                     }
                 }
                 // DO NOT encode '%'.  If you do, then for starters,
@@ -745,10 +744,7 @@
                 if (ch == ' ') {
                     out.write('+');
                 } else {
-                    // ISO-8859-1.  Blindly assume the character will be < 255.
-                    // Not much we can do if it isn't.
-                    writeURIDoubleHex(out, ch);
-
+                    encodeURIString(out, textBuff, "utf-8", i, i + 1);
                 }
             }
             // DO NOT encode '%'.  If you do, then for starters,

Index: test/com/sun/faces/util/TestHtmlUtils.java
===================================================================
--- test/com/sun/faces/util/TestHtmlUtils.java	(revision 8390)
+++ test/com/sun/faces/util/TestHtmlUtils.java	(working copy)
@@ -77,6 +77,15 @@
         testURLEncoding("/index.jsf?joe=10&f=20&amp;",
                         "/index.jsf?joe=10&amp;f=20&amp;",
                         "/index.jsf?joe=10&amp;f=20&amp;");
+        //Test URL with non-ascii characters before the query string
+        testURLEncoding("/indéx.jsf",
+                        "/ind%C3%A9x.jsf",
+                        "/ind%C3%A9x.jsf");
+        //Test URL with non-ascii characters both before the query string, and in it
+        testURLEncoding("/indéx.jsf?joé=10",
+                        "/ind%C3%A9x.jsf?jo%C3%A9=10",
+                        "/ind%C3%A9x.jsf?jo%C3%A9=10");
+
     }
 

SECTION: New Files

No new files