Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8455623
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T12:19:53+00:00 2026-06-10T12:19:53+00:00

I need to display some HTML in Grails Error Messages, to mark some content

  • 0

I need to display some HTML in Grails Error Messages, to mark some content for an external System I cannot influence. Its just some simple span tags, with a class=”notranslate” attribute. By default, the HTML will get escaped, so I disabled the codec in the tag, which leads to another problem:

Now everything the User enters will be displayed in the HTML of the Page, which enables easy XSS…
My solution for now is to only disable the HTML Codec for this Page, and use custom error messages, that do not include what the user entered, but that seems rather clumsy to me.

I also saw that there might be the possibility to fiddle around with the MessageSource, but I do not like to change to much in the bowels of Grails. Another Idea I had was to create a custom Filter, that lets only the HTML I approve of through. I also discarded this idea, it felt like I was handling the problem on the wrong abstraction level.

Any Idea how to solve this problem?

TL;DR
I need to wrap variable parts of the error message in tags.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T12:19:54+00:00Added an answer on June 10, 2026 at 12:19 pm

    In order not to get an HTML encoded error flash message, one can use the following:

    <g:hasErrors bean="${editingInstance}">
        <div class="errors">
            <g:renderErrors bean="${editingInstance}" codec="none"/>
        </div>
    </g:hasErrors>
    

    The ‘codec’ attribute will be used in ValidationTagLib.groovy:

    Closure renderErrors = { attrs, body ->
        def renderAs = attrs.remove('as')
        if (!renderAs) renderAs = 'list'
    
        if (renderAs == 'list') {
            def codec = attrs.codec ?: 'HTML'
            if (codec == 'none') codec = ''
    
            [...]
        }
        [...]
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to display some HTML content as it will be printed. Basically, I
Hi I'm developing a WPF application. I need to display some HTML content from
I would need to display some basic HTML (just some paragraphs, unordered lists and
I need to display some portion of html in my windows forms application. It's
I need to retrieve some HTML tags from a database to display in my
I'm using the WPF WebBrowser component to display some very simple HTML content. However,
I'm working on a Grails application and I need to display some reports and
I use a thickbox to display some html content in a modal window. I
I'm using a Flash TextField control to display some HTML content inside a Flash
I need to display some data(some text message) from a URL* (an HTML file)

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.