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:
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.
fixed on dev (38739) and 6.0.x (38768)