3 Replies Latest reply on Oct 1, 2007 8:12 AM by pmuir

    m:subject always HTML encodes strings

      Hello,
      It seems that when using seam to send email with m:message and the rest (like: m:subject) you'll always end up with HTML-encoded strings. Anyone noticed this?

      If I have:


      <m:subject>ääääää</m:subject>


      The subject with "äää"s will always end up as HTML encoded string:
      & #228; & #228; & #228; (no space between & and #. I just added it here )

      Is this the correct behaviour or am I doing something wrong?



        • 1. Re: m:subject always HTML encodes strings

          Ups, forgot to tell that org.jboss.seam.mail.ui.context.MailResponseWriter write method uses the delegate (which happens to be org.apache.myfaces.shared_impl.renderkit.html.HtmlResponseWriterImpl ) for both plain and html outputs.

           @Override
           public void write(String str) throws IOException
           {
           if (TEXT_PLAIN_CONTENT_TYPE.equals(getContentType()))
           {
           delegate.write(str);
           }
           else
           {
           delegate.write(str);
           }
           }
          


          • 2. Re: m:subject always HTML encodes strings

            FaceletsRendered$Context.wrap() calls facesContext.setResponseWriter with null character encoding. This causes HtmlRenderKitImpl.createResponseWriter to default to ISO-8859-1 encoding which further causes the usage of UnicodeEncoder (delegate.write(String) in MailResponseWriter.write(String)) later on which translates äää -->

             // Wrap the ResponseWriter
             originalResponseWriter = facesContext.getResponseWriter();
             facesContext.setResponseWriter(facesContext.getRenderKit().createResponseWriter(writer,
             null, null));
            


            Class org.apache.myfaces.shared_impl.renderkit.html.HtmlResponseWriterImpl.java:
            
             public void write(String str) throws IOException
             {
             closeStartTagIfNecessary();
             // empty string commonly used to force the start tag to be closed.
             // in such case, do not call down the writer chain
             if (str.length() > 0)
             {
             // Don't bother encoding anything if chosen character encoding is UTF-8
             if (UTF8.equals(_characterEncoding)) _writer.write(str);
             else _writer.write(UnicodeEncoder.encode(str) );
             }
             }
            


            • 3. Re: m:subject always HTML encodes strings
              pmuir

              Please file a JIRA issue for this.