Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-2793

URL encoding of artifact string doesn't work for name with space

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Major Major
    • other
    • None
    • Platform: All, OS: Linux

      http://fisheye4.atlassian.com/browse/hudson/trunk/hudson/main/core/src/main/java
      /hudson/model/DirectoryBrowserSupport.java?r1=13601&r2=14106
      Line #: 465/468

      which is part of JENKINS-2379 (https://hudson.dev.java.net/issues/show_bug.cgi?
      id=2379) which if part of changeset
      (http://fisheye4.cenqua.com/changelog/hudson/?cs=14106)

      introduced a bug during the encoding spaces in the filePath by switching it from
      %20 to a + sign.

      For example:
      If you are archiving artifacts using the following path (relative to the
      workspace) "my handy dandy build dir/output/**", will result in
      "http://server/hudson/job/job%20name/lastSuccessfulBuild/my+hand+dandy+build+dir
      /output/any.jar" in the artifact list.

      It should be:
      "http://server/hudson/job/job%20name/lastSuccessfulBuild/my%20hand%20dandy%20bui
      ld%20dir/output/any.jar"
      or: "http://server/hudson/job/job name/lastSuccessfulBuild/my hand dandy
      build%20dir/output/any.jar"
      for it to work

      Trying to download the url with the embedded + signes results in a 404 HTTP
      status page.

      Looking at http://java.sun.com/j2se/1.5.0/docs/api/java/net/URLEncoder.html
      shows that the + signs are expected in the encoding.

      Hudson is installed on a Linux box and using Glassfish v2 as the J2EE container.
      I tested this using Chrome, Internet Explorer, and Firefox

      The browser that I used itendentifies it self thusly:
      Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US) AppleWebKit/525.19 (KHTML, like
      Gecko) Chrome/1.0.154.42 Safari/525.19 RPT-HTTPClient/0.3-2

      Could it be the the broswer is using en-US and encoding is for UTF-8?

      Thanks,
      – Tom.

          [JENKINS-2793] URL encoding of artifact string doesn't work for name with space

          Alan Harder added a comment -

          oops, URLEncode.encode is only for content in the query string.. for path of URL
          I should have used hudson.Util.encode().

          Alan Harder added a comment - oops, URLEncode.encode is only for content in the query string.. for path of URL I should have used hudson.Util.encode().

          Alan Harder added a comment -
              • Issue 2795 has been marked as a duplicate of this issue. ***

          Alan Harder added a comment - Issue 2795 has been marked as a duplicate of this issue. ***

          Alan Harder added a comment -

          Util.encode was not sufficient either.. I created a new Util.rawEncode and used
          that instead. Also add xmlEscape call on the text of each link, so any & or <
          in filenames is properly escaped for html display.

          Alan Harder added a comment - Util.encode was not sufficient either.. I created a new Util.rawEncode and used that instead. Also add xmlEscape call on the text of each link, so any & or < in filenames is properly escaped for html display.

          Code changed in hudson
          User: : mindless
          Path:
          trunk/hudson/main/core/src/main/java/hudson/Util.java
          trunk/hudson/main/core/src/main/java/hudson/model/DirectoryBrowserSupport.java
          trunk/hudson/main/core/src/main/java/hudson/model/Run.java
          trunk/hudson/main/core/src/main/resources/hudson/model/DirectoryBrowserSupport/dir.jelly
          trunk/hudson/main/core/src/main/resources/hudson/model/Run/artifacts-index.jelly
          trunk/hudson/main/core/src/main/resources/lib/hudson/artifactList.jelly
          trunk/hudson/main/core/src/test/java/hudson/UtilTest.java
          trunk/www/changelog.html
          http://fisheye4.cenqua.com/changelog/hudson/?cs=14355
          Log:
          [FIXED JENKINS-2793] Fix from JENKINS-2379 introduced a bug for artifact/workspace
          filenames with spaces.

          • Added new Util.rawEncode which encodes the right set of characters (based on
            RFC1738) and deprecated Util.encode which only encodes non-ASCII. Unit test too.
          • Change previous fix to use Util.rawEncode instead of URLEncoder.encode
          • New fix: add h.xmlEscape call for each displayed filename in artifacts/workspace
            so & and < are encoded for HTML display
          • Add all these fixes in Run/artifacts-index.jelly which wasn't included before

          SCM/JIRA link daemon added a comment - Code changed in hudson User: : mindless Path: trunk/hudson/main/core/src/main/java/hudson/Util.java trunk/hudson/main/core/src/main/java/hudson/model/DirectoryBrowserSupport.java trunk/hudson/main/core/src/main/java/hudson/model/Run.java trunk/hudson/main/core/src/main/resources/hudson/model/DirectoryBrowserSupport/dir.jelly trunk/hudson/main/core/src/main/resources/hudson/model/Run/artifacts-index.jelly trunk/hudson/main/core/src/main/resources/lib/hudson/artifactList.jelly trunk/hudson/main/core/src/test/java/hudson/UtilTest.java trunk/www/changelog.html http://fisheye4.cenqua.com/changelog/hudson/?cs=14355 Log: [FIXED JENKINS-2793] Fix from JENKINS-2379 introduced a bug for artifact/workspace filenames with spaces. Added new Util.rawEncode which encodes the right set of characters (based on RFC1738) and deprecated Util.encode which only encodes non-ASCII. Unit test too. Change previous fix to use Util.rawEncode instead of URLEncoder.encode New fix: add h.xmlEscape call for each displayed filename in artifacts/workspace so & and < are encoded for HTML display Add all these fixes in Run/artifacts-index.jelly which wasn't included before

          Alan Harder added a comment -

          in 1.273

          Alan Harder added a comment - in 1.273

            mindless Alan Harder
            tdjordan Tom Jordan
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved: