Bug 108430 - PageTransformer uses incorrect encoding
PageTransformer uses incorrect encoding
Status: CLOSED RAWHIDE
Product: Red Hat Web Application Framework
Classification: Retired
Component: ui (Show other bugs)
6.0
All Linux
medium Severity medium
: ---
: ---
Assigned To: ccm-bugs-list
Jon Orris
:
Depends On:
Blocks: 100952
  Show dependency treegraph
 
Reported: 2003-10-29 09:36 EST by Randy Graebner
Modified: 2007-04-18 12:58 EDT (History)
0 users

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2003-12-15 13:47:09 EST
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 Randy Graebner 2003-10-29 09:36:55 EST
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 10:19:41 EST
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 12:51:06 EST
fixed on dev (38739) and 6.0.x (38768)

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