[ 
https://issues.apache.org/jira/browse/VELTOOLS-77?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12473353
 ] 

Niall Pemberton commented on VELTOOLS-77:
-----------------------------------------

>From a Struts perspective I would be against making this kind of change in the 
>equivalent Struts tag and my advice would be "don't put markup in your 
>messages" if it was requsted as a feature in Struts  - that doesn't seem like 
>too much of a restriction for the example given (putting the field name in 
>italics).

Also it is easy for people to create their own custom implementations of the 
tool to do this if they wanted - by overriding the escapeJavascript() method

    protected String escapeJavascript(String str)
    {
        if(null == str) {
            return null;

        str = super.escapeJavascript(str);
 
        return str.replaceAll("<[^>]*>", "")
            .replaceAll("&amp;", "&")
            .replaceAll("&lt;", "<")
            .replaceAll("&gt;", ">")
            .replaceAll("&quot;", "\"")
            .replaceAll("&apos;", "'")
            ;
    }



> Inconsistency between display in javascript and non-javascript error messages 
> containing HTML
> ---------------------------------------------------------------------------------------------
>
>                 Key: VELTOOLS-77
>                 URL: https://issues.apache.org/jira/browse/VELTOOLS-77
>             Project: Velocity Tools
>          Issue Type: Bug
>          Components: VelocityStruts
>         Environment: Struts 1.3.5 / Velocity 1.4 / Velocity Tools 1.2
>            Reporter: Christopher Schultz
>            Priority: Trivial
>         Attachments: VELTOOLS-77.diff
>
>
> When error messages contain HTML markup, the messages are displayed as 
> expected by $error.getMsgs(fieldName), but not in javascript messages.
> Easy to demonstrate:
> 1. Start with typical struts/validator/velocity/velocity-tools setup
> 2. Modify stock error message "errors.required" from
>     errors.required=The field {0} is required.
> to:
>     errors.required=The field <i>{0}</i> is required.
> 3. Induce form rejection (required field) with javascript turned OFF
> Result: Error message is displayed with fieldname in italics.
> 4. Repeat form failure with javascript turned ON
> Result: Error message is displayed in javascript alert with unsightly <i> and 
> </i> markup displayed. (Same problem occurs with more likely things such as 
> HTML entities (i.e. &amp;)).
> Expected: Markup removed?
> I realize that javascript popups are not generally expected to properly 
> render markup. Perhaps error messages put into javascript validation could 
> have markup removed. I also realize that this is a non-trivial fix and kind 
> of a minefield. ;)
> Feel free to re-categorize this issue as something other than a "bug". I just 
> figured that inconsistent behavior (IMO) called for "bug" status. Since I'm 
> not offering a solution just yet, I didn't want to categorize it as an 
> "improvement".

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to