Bug 120381 - wrong URL parameter encoding PageState.toURL()
wrong URL parameter encoding PageState.toURL()
Status: NEW
Product: Red Hat Web Application Framework
Classification: Retired
Component: other (Show other bugs)
6.0
All Linux
medium Severity medium
: ---
: ---
Assigned To: ccm-bugs-list
Jon Orris
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2004-04-08 04:16 EDT by durnez
Modified: 2008-05-01 11:39 EDT (History)
0 users

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed:
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description durnez 2004-04-08 04:16:49 EDT
Description of problem:
This problem appeared for french characters (eg : bébé).

Default browser encoding is ISO-8859-1.
Default server encoding is UTF-8.
First HTTP request :
/ccm/content/search.jsp?g11n.enc=UTF-8&terms=b%C3%A9b%C3%A9

When a parameter is carried by HTTP request (like bébé), server
decodes it properly from ISO-8859-1 to UTF-8 (see
Globalization.decodeParameter(..)).

However, when a link URL is generated by the server, and that
generated URL carries this parameter (eg :
ControlLink.generateURL(..)), all associated parameters are simply
added to URL, without reverse encoding.

This lead to a wrong encoded link URL : parameters should be
ISO-8859-1 encoded, but in fact there are UTF-8 encoded.

When this URL is used by the user, new incoming parameter (second HTTP
request) will be decoded from ISO-8859-1 to UTF-8.

Which gives 'in fine' a parameter value to 'b' instead of 'bébé'.


Summary :

First HTTP request :
/ccm/content/search.jsp?g11n.enc=UTF-8&terms=b%C3%A9b%C3%A9

Second HTTP request (i.e. generated link URL) :
/ccm/content/search.jsp?terms=b%E9b%E9&g11n.enc=UTF-8


Version-Release number of selected component (if applicable):
WAF 6.0.1

How reproducible:
always

Bug correction done at perforce change #42034 : PageState.toURL()
modified :

- * @version $Id:
//ps/proj/cf-fr/dev/carrefour/src/com/arsdigita/bebop/PageState.java#1 $
+ * @version $Id:
//core-platform/6.0/src/com/arsdigita/bebop/PageState.java#1 $
  */
 public class PageState {
                                                                     
                                                                     
                 
     public static final String versionId =
-        "$Id:
//ps/proj/cf-fr/dev/carrefour/src/com/arsdigita/bebop/PageState.java#1
$ " +
-        "by $Author: vdurnez $, $DateTime: 2004/04/08 04:04:14 $";
+        "$Id:
//core-platform/6.0/src/com/arsdigita/bebop/PageState.java#1 $ " +
+        "by $Author: dennis $, $DateTime: 2003/08/18 23:52:40 $";
                                                                     
                                                                     
                 
     private static final Logger s_log =
Logger.getLogger(PageState.class);
                                                                     
                                                                     
                 
@@ -909,28 +904,7 @@
                 final String value = data.marshal();
                                                                     
                                                                     
                 
                 if (value != null) {
-                       // parameter value must be encoded with
browser charset (.
-                                       String serverCharset =
m_request.getParameter(Globalization.ENCODING_PARAM_NAME);
-                                       if (serverCharset == null ||
serverCharset.length() == 0) {
-                                               serverCharset =
Globalization.getDefaultCharset(getLocale(m_request));
-                                       }
-                                       String  browserCharset =
Globalization.getDefaultCharset(m_request);
-
-                       if (!
browserCharset.equalsIgnoreCase(serverCharset))
-                       {
-                               String encodedValue=null;
-                       try {
-                               // encode value from server charset to
browser charset
-                                               encodedValue= new
String (value.getBytes(serverCharset), browserCharset);
-                                       } catch
(UnsupportedEncodingException ex) {
-                                                              
s_log.fatal("PageState.toURL(): encoding issue when changing  '"+value
+"' to '"+browserCharset + " encoding", ex);
-                       }
-                                      
s_log.debug("PageState.toURL(): parameter '"+value+ "' encoded into
charset "+browserCharset+" => '"+encodedValue+"'");
-                                       params.setParameter(key,
encodedValue);
-                                       }
-                                       else
                                        params.setParameter(key, value);
-
                 }
             }
@@ -944,20 +918,6 @@
         return URL.request(m_request, params);
     }
                                                                     
                                                                     
                 
-    /**
-     * copied from com.arsdigita.globalization.Globalization
-     */
-       private static java.util.Locale getLocale(HttpServletRequest
req) {
-               java.util.Locale l = Kernel.getContext().getLocale();
-               if (l == null) {
-                       l = req.getLocale();
-               }
-               if (l == null) {
-                       l = java.util.Locale.getDefault();
-               }
-               return l;
-       }
-

Note You need to log in before you can comment on or make changes to this bug.