struts-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "James House (JIRA)" <j...@apache.org>
Subject [jira] Updated: (WW-3571) Anchor tag is providing a default value for href attribute when it should not
Date Fri, 11 Feb 2011 20:58:57 GMT

     [ https://issues.apache.org/jira/browse/WW-3571?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

James House updated WW-3571:
----------------------------

    Description: 
The Anchor tag is providing a default value for href attribute when it should not.

Previous versions of Struts2 did not do this, and in fact the documentation for the tag also
says there is no default value.

However it is placing a default value of the current URL, rather than leaving the href attribute
off altogether.  (it is legal per HTML to not have an href attribute, and in fact we had existing
code that was trying to purposely leave it off, but now instead of being left off, it is rendered
with the current URL).

I believe the problem was introduced with the changes related to WW-3037.   This block of
code (from Anchor.java) precisely:

{code}
    @Override
    protected void evaluateExtraParams() {
        super.evaluateExtraParams();

        if (href != null)
            addParameter("href", ensureAttributeSafelyNotEscaped(findString(href)));
        else {
            //no href, build it from URL attributes
            StringWriter sw = new StringWriter();
            urlRenderer.beforeRenderUrl(urlProvider);
            urlRenderer.renderUrl(sw, urlProvider);
            String builtHref = sw.toString();
            if (StringUtils.isNotEmpty(builtHref))
                addParameter("href", ensureAttributeSafelyNotEscaped(builtHref));
        }
    }
{code}

To preserve documented and previous functionality of allowing href to not be rendered in the
tag, the entire "else" block should be removed (of course that significantly negates WW-3037
- which apparently didn't think about the fact that it is legit to not have an href for the
anchor).




  was:
The Anchor tag is providing a default value for href attribute when it should not.

Previous versions of Struts2 did not do this, and in fact the documentation for the tag also
says there is no default value.

However it is placing a default value of the current URL, rather than leaving the href attribute
off altogether.  (it is legal per HTML to not have an href attribute, and in fact we had existing
code that was trying to purposely leave it off, but now instead of being left off, it is rendered
with the current URL).

I believe the problem was introduced with the changes related to WW-3037.   This block of
code (from Anchor.java) precisely:

{code}
    @Override
    protected void evaluateExtraParams() {
        super.evaluateExtraParams();

        if (href != null)
            addParameter("href", ensureAttributeSafelyNotEscaped(findString(href)));
        else {
            //no href, build it from URL attributes
            StringWriter sw = new StringWriter();
            urlRenderer.beforeRenderUrl(urlProvider);
            urlRenderer.renderUrl(sw, urlProvider);
            String builtHref = sw.toString();
            if (StringUtils.isNotEmpty(builtHref))
                addParameter("href", ensureAttributeSafelyNotEscaped(builtHref));
        }
    }
{code}

To preserve documented and previous functionality of allowing href to not be rendered in the
tag, the entire "else" block should be removed.




> Anchor tag is providing a default value for href attribute when it should not
> -----------------------------------------------------------------------------
>
>                 Key: WW-3571
>                 URL: https://issues.apache.org/jira/browse/WW-3571
>             Project: Struts 2
>          Issue Type: Bug
>    Affects Versions: 2.1.8, 2.2.1.1
>            Reporter: James House
>            Assignee: Maurizio Cucchiara
>
> The Anchor tag is providing a default value for href attribute when it should not.
> Previous versions of Struts2 did not do this, and in fact the documentation for the tag
also says there is no default value.
> However it is placing a default value of the current URL, rather than leaving the href
attribute off altogether.  (it is legal per HTML to not have an href attribute, and in fact
we had existing code that was trying to purposely leave it off, but now instead of being left
off, it is rendered with the current URL).
> I believe the problem was introduced with the changes related to WW-3037.   This block
of code (from Anchor.java) precisely:
> {code}
>     @Override
>     protected void evaluateExtraParams() {
>         super.evaluateExtraParams();
>         if (href != null)
>             addParameter("href", ensureAttributeSafelyNotEscaped(findString(href)));
>         else {
>             //no href, build it from URL attributes
>             StringWriter sw = new StringWriter();
>             urlRenderer.beforeRenderUrl(urlProvider);
>             urlRenderer.renderUrl(sw, urlProvider);
>             String builtHref = sw.toString();
>             if (StringUtils.isNotEmpty(builtHref))
>                 addParameter("href", ensureAttributeSafelyNotEscaped(builtHref));
>         }
>     }
> {code}
> To preserve documented and previous functionality of allowing href to not be rendered
in the tag, the entire "else" block should be removed (of course that significantly negates
WW-3037 - which apparently didn't think about the fact that it is legit to not have an href
for the anchor).

-- 
This message is automatically generated by JIRA.
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Mime
View raw message