Click
  1. Click
  2. CLK-78

actionLink should urlencode the link it generates

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Incomplete
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: core
    • Labels:
      None
    • Environment:
      click 0.18

      Description

      I'm using $myActionLink.getHref($blabla).

      I would expect the resulting link to be url encoded.

        Activity

        Hide
        Malcolm Edgar added a comment -

        Hi Steven,

        the link is encoded, please see source below:

        public String getHref(Object value) {
        String uri = getContext().getRequest().getRequestURI();

        StringBuffer buffer =
        new StringBuffer(uri.length() + getName().length() + 40);

        buffer.append(uri);
        buffer.append("?");
        buffer.append(ACTION_LINK);
        buffer.append("=");
        buffer.append(getName());
        if (value != null)

        { buffer.append("&"); buffer.append(VALUE); buffer.append("="); buffer.append(value); }

        return getContext().getResponse().encodeURL(buffer.toString());
        }

        Show
        Malcolm Edgar added a comment - Hi Steven, the link is encoded, please see source below: public String getHref(Object value) { String uri = getContext().getRequest().getRequestURI(); StringBuffer buffer = new StringBuffer(uri.length() + getName().length() + 40); buffer.append(uri); buffer.append("?"); buffer.append(ACTION_LINK); buffer.append("="); buffer.append(getName()); if (value != null) { buffer.append("&"); buffer.append(VALUE); buffer.append("="); buffer.append(value); } return getContext().getResponse().encodeURL(buffer.toString()); }
        Hide
        Malcolm Edgar added a comment -

        Hi Steven,

        I will close this issue, unless you can confirm you are having some problems with this.

        regards Malcolm Edgar

        Show
        Malcolm Edgar added a comment - Hi Steven, I will close this issue, unless you can confirm you are having some problems with this. regards Malcolm Edgar
        Hide
        Steven Van Hoof added a comment -

        This is an example url I get:

        /cp/view.htm?actionLink=navigateDirectLink&value=root/rack 1/shelf 1/slot 9

        I passed "root/rack 1/shelf 1/slot 9" to the getHref function from my velocity template.

        I'm using click 0.18.

        Show
        Steven Van Hoof added a comment - This is an example url I get: /cp/view.htm?actionLink=navigateDirectLink&value=root/rack 1/shelf 1/slot 9 I passed "root/rack 1/shelf 1/slot 9" to the getHref function from my velocity template. I'm using click 0.18.
        Hide
        Malcolm Edgar added a comment -

        Thanks Steven,

        I will look into this.

        regards Malcolm

        Show
        Malcolm Edgar added a comment - Thanks Steven, I will look into this. regards Malcolm
        Hide
        Malcolm Edgar added a comment -

        Hi Steven,

        there is a bug in Click 0.18 ActionLink where its rendering the & character as & and I think this is causing the issue you are having with an incorrect value being returned from the ActionLink.

        This bug is fixed in CVS, could you try patching you code with the change and see if it fixes your problem. I cant reproduce the issue you are having against the head stream (0.19-dev).

        regards Malcolm Edgar

        Show
        Malcolm Edgar added a comment - Hi Steven, there is a bug in Click 0.18 ActionLink where its rendering the & character as & and I think this is causing the issue you are having with an incorrect value being returned from the ActionLink. This bug is fixed in CVS, could you try patching you code with the change and see if it fixes your problem. I cant reproduce the issue you are having against the head stream (0.19-dev). regards Malcolm Edgar
        Hide
        Steven Van Hoof added a comment -

        Malcolm,

        Thanks a lot.

        regards,

        Steven

        Show
        Steven Van Hoof added a comment - Malcolm, Thanks a lot. regards, Steven
        Hide
        Malcolm Edgar added a comment -

        Fixed in CVS, will be available in release 0.19

        This bug is actually due to & in generated URL.

        Show
        Malcolm Edgar added a comment - Fixed in CVS, will be available in release 0.19 This bug is actually due to & in generated URL.
        Hide
        Malcolm Edgar added a comment -

        This issue needs more testing for & character handling in parameter values

        Show
        Malcolm Edgar added a comment - This issue needs more testing for & character handling in parameter values
        Hide
        Malcolm Edgar added a comment -

        Hi Christian,

        please apply your suggested fix. As detailed by Naoki please apply the ClickApp#getCharset(). The Context object will need to be extended to expose the charset, adding a getter method:

        public String getCharset();

        regards Malcolm Edgar

        Show
        Malcolm Edgar added a comment - Hi Christian, please apply your suggested fix. As detailed by Naoki please apply the ClickApp#getCharset(). The Context object will need to be extended to expose the charset, adding a getter method: public String getCharset(); regards Malcolm Edgar
        Hide
        Christian Essl added a comment -

        Checked in the changes as described on the mailinglist:

        • added Context.getCharset() which returns the charset of ClickApp or if null ISO-8859-1
        • added ClickUtils.encodeURLParamter() which uses only the charset of Context.getCharset()
        • updated ActionLink.getHref() and ActionButton to use the ClickUtils method.

        Christian

        Show
        Christian Essl added a comment - Checked in the changes as described on the mailinglist: added Context.getCharset() which returns the charset of ClickApp or if null ISO-8859-1 added ClickUtils.encodeURLParamter() which uses only the charset of Context.getCharset() updated ActionLink.getHref() and ActionButton to use the ClickUtils method. Christian

          People

          • Assignee:
            Christian Essl
            Reporter:
            Steven Van Hoof
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development