Use the Java URI Class instead of the Java URLEncode Class with the urlEncode Jira smart value function

XMLWordPrintable

      Summary

      Currently the urlEncode Jira smart value function uses the Java URLEncode class (java.net.URLEncoder) for encoding.

      Per the class documentation when handling blank spaces, it encodes these as a + character:

      The space character " " is converted into a plus sign "+".

      On the other hand, the Java URI class (java.net.URI) encodes blank spaces as %20:

      An illegal character is quoted simply by encoding it. The space character, for example, is quoted by replacing it with "%20". UTF-8 contains US-ASCII, hence for US-ASCII characters this transformation has exactly the effect required by RFC 2396.

      When using smart values that are URL encoded in this manner as part of a URI path, depending on the position of the encoded value, it can break the URL as the + character will be taken as exactly that as opposed to treated as a blank value.

      Workaround

      The + character can be replaced as part of the smart value using the replace() or replaceAll() functions. Further details on the workaround can be found on the article:

            Assignee:
            Unassigned
            Reporter:
            Andras M.
            Votes:
            3 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated: