Uploaded image for project: 'XWiki Platform'
  1. XWiki Platform
  2. XWIKI-13557

Wrong encoding when creating URLs

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • Major
    • 8.3-milestone-1
    • 7.4
    • Old Core
    • None
    • Unit
    • Unknown
    • N/A
    • N/A

    Description

      Test proving the problem:

          @Test
          public void createURLWhenCharactersNeedToBeEncoded() throws Exception
          {
              // Note: The query string is not encoded, and used as is. It's the responsibility of the caller to
              // url-encode it.
              // See see http://stackoverflow.com/a/29948396/153102 for a good explanation of URL encoding:
              // - space in path part must be encoded with %20 (and not "+"). "+" character should be left as is.
              // - space in query string part and fragment part can be encoded with "+" or "%20". "+" character should be
              //   encoded with "%2B"
              URL url = this.urlFactory.createURL("a b.c+d", "e f", "view", "g=h+i", "j k+l", this.oldcore.getXWikiContext());
              assertEquals("http://127.0.0.1/xwiki/bin/view/a%20b/c+d/e%20f?g=h+i#j%20k%2Bl", url.toString());
          }
      

      Expected :http://127.0.0.1/xwiki/bin/view/a%20b/c+d/e%20f?g=h+i#j%20k%2Bl
      Actual :http://127.0.0.1/xwiki/bin/view/a+b/c%2Bd/e+f?g=h+i#j+k%2Bl

      Problem it's causing: http://jira.xwiki.org/browse/XWIKI-13556?focusedCommentId=91999&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-91999

      Attachments

        Issue Links

          Activity

            People

              vmassol Vincent Massol
              vmassol Vincent Massol
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: