Bug 108430

Summary: PageTransformer uses incorrect encoding
Product: [Retired] Red Hat Web Application Framework Reporter: Randy Graebner <randyg>
Component: uiAssignee: ccm-bugs-list
Status: CLOSED RAWHIDE QA Contact: Jon Orris <jorris>
Severity: medium Docs Contact:
Priority: medium    
Version: 6.0   
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2003-12-15 18:47:09 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 100952    

Description Randy Graebner 2003-10-29 14:36:55 UTC
Description of problem:
The PageTransformer has a method named getPrintWriter that tries to get the
PrintWriter from the response.  The encoding for that PrintWriter is grabbed
from the content-type of the response or is set to ISO-8859-1 if the type has
not been set.  Unfortunately, the PageTransformer gets the writer and then sets
the type which means that it creates incorrect html when writing non-english
characters.

There are two ways to fix it.  The patch included below just moved the
repsective content-type declarations.  The other option is to make the
getPrintWriter also set the type.  This would guarantee that we never run in to
this problem again with this class.  I would like to see the second solution
implemented but I defer to you to decide what is the "correct" way to do it.

Here is the patch for the solution that I do not think should be used.  I am
only including it so that you can see what the problem is.

[randyg@graebner intragroupe]$ diff -uw
intragroupe/src/com/arsdigita/bebop/page/PageTransformer.java
core-platform/src/com/arsdigita/bebop/page/PageTransformer.java 
--- intragroupe/src/com/arsdigita/bebop/page/PageTransformer.java	Wed Oct 29
09:29:22 2003
+++ core-platform/src/com/arsdigita/bebop/page/PageTransformer.java	Tue Aug
//ps/proj/cf-intragroupe/dev/intragroupe/src/com/arsdigita/bebop/page/PageTransformer.java#1
$
@@ -172,21 +180,14 @@

         final String output = req.getParameter("output");
 
         if (output == null) {
             DeveloperSupport.startStage("PresMgr transform");
 
-            // Before sending output, make sure we set content
-            // type.
-            resp.setContentType("text/html; " +
-                                "charset=" + charset);
-
             final PrintWriter writer = getWriter(resp, charset);
 
             // If no cache policy is set by ealier dispatcher,
@@ -201,6 +202,10 @@
                 // No default cache policy at all!
             }
 
+            // Before sending output, make sure we set content
+            // type.
+            resp.setContentType("text/html; " +
+                                "charset=" + charset);
             // Why is req.getContentType() null ?
             //resp.setContentType(req.getContentType() + "; " +
             //                    "charset=" + charset);
@@ -278,10 +283,9 @@
             }
         } else {
             if (output.equals("xml")) {
-                resp.setContentType("text/xml; charset=" + charset);
-
                 final PrintWriter writer = getWriter(resp, charset);
 
+                resp.setContentType("text/xml; charset=" + charset);
                 DispatcherHelper.forceCacheDisable(resp);
 
                 writer.println(doc.toString(true));

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

How reproducible:
Always

Steps to Reproduce:
1. Set the DefaultPresentationManager to be PageTransformer and create a content
item with non-english characters such as "oilà l'été èàp_èàopè"
2.
3.
    
Actual results:
? instead of the character

Expected results:
To see the actual character

Additional info:

Comment 1 Vadim Nasardinov 2003-10-29 15:19:41 UTC
Ah, a bug in my code.

History buffs may want to check out
http://porter.boston.redhat.com/acs5/sdm/one-ticket?ticket_id=212658


> The encoding for that PrintWriter is grabbed from the content-type of
> the response or is set to ISO-8859-1 if the type has not been set.

This should read,

  ".. or is set to the default system encoding..."

It doesn't have to be ISO-8859-1.


Comment 2 Archit Shah 2003-12-12 17:51:06 UTC
fixed on dev (38739) and 6.0.x (38768)