Hi Sergiu,

On Dec 26, 2009, at 6:48 PM, sdumitriu (SVN) wrote:

> Author: sdumitriu
> Date: 2009-12-26 18:48:37 +0100 (Sat, 26 Dec 2009)
> New Revision: 25938
>
> Modified:
>   platform/core/trunk/xwiki-core/src/main/java/com/xpn/xwiki/util/ 
> Util.java
> Log:
> XWIKI-4704: Always use UTF-8 for URL encoding
> Done.

Could we have some comments below to explain why we're using UTF8 with  
some link pointing to the RFC you mentioned? I think it would help  
remember it for the future.

Thanks
-Vincent

>
> Modified: platform/core/trunk/xwiki-core/src/main/java/com/xpn/xwiki/ 
> util/Util.java
> ===================================================================
> --- platform/core/trunk/xwiki-core/src/main/java/com/xpn/xwiki/util/ 
> Util.java     2009-12-26 00:29:36 UTC (rev 25937)
> +++ platform/core/trunk/xwiki-core/src/main/java/com/xpn/xwiki/util/ 
> Util.java     2009-12-26 17:48:37 UTC (rev 25938)
> @@ -29,8 +29,6 @@
> import java.io.Reader;
> import java.io.StreamTokenizer;
> import java.io.StringReader;
> -import java.net.URLDecoder;
> -import java.net.URLEncoder;
> import java.util.ArrayList;
> import java.util.Date;
> import java.util.HashMap;
> @@ -46,6 +44,7 @@
> import javax.xml.parsers.DocumentBuilderFactory;
> import javax.xml.parsers.ParserConfigurationException;
>
> +import org.apache.commons.httpclient.util.URIUtil;
> import org.apache.commons.io.FileUtils;
> import org.apache.commons.io.IOUtils;
> import org.apache.commons.lang.ArrayUtils;
> @@ -67,7 +66,6 @@
> import org.xml.sax.SAXException;
> import org.xwiki.container.Container;
>
> -import com.novell.ldap.util.Base64;
> import com.xpn.xwiki.XWikiContext;
> import com.xpn.xwiki.XWikiException;
> import com.xpn.xwiki.monitor.api.MonitorPlugin;
> @@ -759,7 +757,7 @@
>     public static String encodeURI(String text, XWikiContext context)
>     {
>         try {
> -            return URLEncoder.encode(text,  
> context.getWiki().getEncoding());
> +            return URIUtil.encodeWithinQuery(text);
>         } catch (Exception e) {
>             return text;
>         }
> @@ -775,17 +773,7 @@
>     public static String decodeURI(String text, XWikiContext context)
>     {
>         try {
> -            // Make sure + is considered as a space
> -            String result = text.replaceAll("\\+", " ");
> -
> -            // It seems Internet Explorer can send us back UTF-8
> -            // instead of ISO-8859-1 for URLs
> -            if (Base64.isValidUTF8(result.getBytes(), false)) {
> -                result = new String(result.getBytes(), "UTF-8");
> -            }
> -
> -            // Still need to decode URLs
> -            return URLDecoder.decode(result,  
> context.getWiki().getEncoding());
> +            return URIUtil.decode(text);
>         } catch (Exception e) {
>             return text;
>         }
_______________________________________________
devs mailing list
[email protected]
http://lists.xwiki.org/mailman/listinfo/devs

Reply via email to