2

Since upgrading an existing application from grails 4.0.3 to 4.0.11 (did not perform interim upgrades, so issue may be somewhere in there) my gsp's that contain raw HTML are now over-encoded (meaning they are showing text like <p>Hello</p>). Is anyone else having this problem? Was there an encoding change that missed documentation (or that I overlooked)?

I have my encodings set to:

grails {
    // other stuff removed for clarity here

    converters.encoding = "UTF-8"

    views {
      "default" {
        codec = "none"
      }
      gsp {
        encoding = "UTF-8"
        htmlcodec = "xml"
        codecs {
          expression = "none"
          scriptlets = "none"
          taglib = "none"
          staticparts = "none"
        }
      }
    }
}

Other info that may help:

  • This only happens when running as a jar; with run-app encoding is respected as usual
Michal_Szulc
  • 4,097
  • 6
  • 32
  • 59
Daniel
  • 3,312
  • 1
  • 14
  • 31
  • Could you provide example PoC, publicly accessible project, please? – Michal_Szulc Aug 24 '21 at 18:22
  • "This only happens when running as a jar; with run-app encoding is respected as usual" - If you file an issue at https://github.com/grails/grails-gsp/issues and link to a sample project we will be happy to address that. Thanks for the feedback! – Jeff Scott Brown Aug 24 '21 at 18:32
  • "Was there an encoding change that missed documentation (or that I overlooked)?" - I think the answer is "no" but even if there was, there is still a problem because `run-app` is behaving differently than the `.jar`. – Jeff Scott Brown Aug 24 '21 at 18:33
  • Thanks all. I'm narrowing in on this and will either file an issue, or publicly admit my own dumb mistake...we'll see which way it goes soon! – Daniel Aug 24 '21 at 19:25

1 Answers1

0

Filing grails bug to report this; minimal reproducible example is available here: https://github.com/danduke/encoding-test

Issue report here: https://github.com/grails/grails-core/issues/12019

EDIT April 2022: The issue report has a workaround now. Thanks to @ascheidmeir!

Daniel
  • 3,312
  • 1
  • 14
  • 31
  • Edit: After reading the dispositions to issue linked below, it wasn't fixed, but a workaround was provided due to the issue arising from springboot changes. Possibly similar ClassLoader workaround? This issue (while not related to encoding) was fixed in grails 4.0.4 and addressed differences in behavior between `run-app` and `war` versions of application. Perhaps this inadvertently caused the encoding problem seen here or at least could be used by developers to track down the problem . https://github.com/grails/grails-core/issues/11545 – Trebla Aug 25 '21 at 11:34
  • The more I read up on the issue I linked above the less confident I am that it's related at all, leaving the comment just in case. – Trebla Aug 25 '21 at 11:42