Uploaded image for project: 'Hippo CMS'
  1. Hippo CMS
  2. CMS-15451

[SaaS] Missing charset on content-type header

    XMLWordPrintable

Details

    • Bug
    • Status: Closed
    • Normal
    • Resolution: Fixed
    • None
    • 15.3.0
    • None
    • None
    • Flagged
    • Quasar
    • Quasar Sprint 312
    • Undetermined
    • Small (1-2)

    Description

      In Tomcat, when you call response.setContentType("application/json") without explicitly setting the character encoding, the default character encoding of ISO-8859-1 is used. However, the default character encoding is not appended to the content type when you call response.getContentType().

      So, if you haven't explicitly called response.setCharacterEncoding() to set a different character encoding, the returned value of response.getContentType() will be "application/json" without the character encoding appended.

      However, if you explicitly invoke response.setCharacterEncoding("UTF-8"), then the character encoding "UTF-8" will be appended to the content type when you call response.getContentType(), resulting in "application/json;charset=UTF-8".

      It turned out that in PageInfoRenderingValve#writeResponse we did never do something like

      response.setCharacterEncoding(pageInfo.getCharacterEncoding());
      

      before setting the content type on the response, and as a result, when the page would come from cache, it does not use the original charset but the default UTF-8 from the HST. With this fix we make sure that

      1. We still have the default response encoding is UTF-8
      2. If the HST rendering for some reason overrides the encoding, it also works for cached pages

      Attachments

        Activity

          People

            aschrijvers Ard Schrijvers
            aschrijvers Ard Schrijvers
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: