You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Brian Stiles (JIRA)" <ji...@apache.org> on 2010/05/20 00:55:55 UTC

[jira] Created: (CONFIGURATION-415) ConfigurationUtils.fileFromURL mangles files with '+' (plus sign) in the name

ConfigurationUtils.fileFromURL mangles files with '+' (plus sign) in the name
-----------------------------------------------------------------------------

                 Key: CONFIGURATION-415
                 URL: https://issues.apache.org/jira/browse/CONFIGURATION-415
             Project: Commons Configuration
          Issue Type: Bug
    Affects Versions: 1.6
            Reporter: Brian Stiles


Attached is a sample program that demonstrates the problem.  The following is the method in ConfigurationUtils in question:

public static File fileFromURL(URL url)
{
...
        return new File(URLDecoder.decode(url.getPath()));
...
}

URLDecoder (poorly named) decodes data encoded in the application/x-www-form-urlencoded MIME format.  This format is commonly used to encode HTML form data.  It is not intended for encoding URLs, though the formats are similar.

The operative difference is that the MIME format allows the use of the plus sign ('+') to represent spaces, whereas URLs must have spaces hex encoded ('%20').  Files may have plus signs in the name, and therefore, decoding the plus sign as a space produces a different path.

See attached code demonstrating the problem.

Reference:  http://www.w3.org/MarkUp/html-spec/html-spec_8.html#SEC8.2.1
and http://www.ietf.org/rfc/rfc1738.txt

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (CONFIGURATION-415) ConfigurationUtils.fileFromURL mangles files with '+' (plus sign) in the name

Posted by "Joerg Schaible (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/CONFIGURATION-415?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12869493#action_12869493 ] 

Joerg Schaible commented on CONFIGURATION-415:
----------------------------------------------

Useful: http://maven.apache.org/plugin-developers/common-bugs.html#Converting_between_URLs_and_Filesystem_Paths

> ConfigurationUtils.fileFromURL mangles files with '+' (plus sign) in the name
> -----------------------------------------------------------------------------
>
>                 Key: CONFIGURATION-415
>                 URL: https://issues.apache.org/jira/browse/CONFIGURATION-415
>             Project: Commons Configuration
>          Issue Type: Bug
>    Affects Versions: 1.6
>            Reporter: Brian Stiles
>         Attachments: FileFromUrlTest.java
>
>
> Attached is a sample program that demonstrates the problem.  The following is the method in ConfigurationUtils in question:
> public static File fileFromURL(URL url)
> {
> ...
>         return new File(URLDecoder.decode(url.getPath()));
> ...
> }
> URLDecoder (poorly named) decodes data encoded in the application/x-www-form-urlencoded MIME format.  This format is commonly used to encode HTML form data.  It is not intended for encoding URLs, though the formats are similar.
> The operative difference is that the MIME format allows the use of the plus sign ('+') to represent spaces, whereas URLs must have spaces hex encoded ('%20').  Files may have plus signs in the name, and therefore, decoding the plus sign as a space produces a different path.
> See attached code demonstrating the problem.
> Reference:  http://www.w3.org/MarkUp/html-spec/html-spec_8.html#SEC8.2.1
> and http://www.ietf.org/rfc/rfc1738.txt

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (CONFIGURATION-415) ConfigurationUtils.fileFromURL mangles files with '+' (plus sign) in the name

Posted by "Brian Stiles (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/CONFIGURATION-415?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Brian Stiles updated CONFIGURATION-415:
---------------------------------------

    Attachment: FileFromUrlTest.java

Sample program to exhibit the bug.

> ConfigurationUtils.fileFromURL mangles files with '+' (plus sign) in the name
> -----------------------------------------------------------------------------
>
>                 Key: CONFIGURATION-415
>                 URL: https://issues.apache.org/jira/browse/CONFIGURATION-415
>             Project: Commons Configuration
>          Issue Type: Bug
>    Affects Versions: 1.6
>            Reporter: Brian Stiles
>         Attachments: FileFromUrlTest.java
>
>
> Attached is a sample program that demonstrates the problem.  The following is the method in ConfigurationUtils in question:
> public static File fileFromURL(URL url)
> {
> ...
>         return new File(URLDecoder.decode(url.getPath()));
> ...
> }
> URLDecoder (poorly named) decodes data encoded in the application/x-www-form-urlencoded MIME format.  This format is commonly used to encode HTML form data.  It is not intended for encoding URLs, though the formats are similar.
> The operative difference is that the MIME format allows the use of the plus sign ('+') to represent spaces, whereas URLs must have spaces hex encoded ('%20').  Files may have plus signs in the name, and therefore, decoding the plus sign as a space produces a different path.
> See attached code demonstrating the problem.
> Reference:  http://www.w3.org/MarkUp/html-spec/html-spec_8.html#SEC8.2.1
> and http://www.ietf.org/rfc/rfc1738.txt

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (CONFIGURATION-415) ConfigurationUtils.fileFromURL mangles files with '+' (plus sign) in the name

Posted by "Oliver Heger (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/CONFIGURATION-415?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12869645#action_12869645 ] 

Oliver Heger commented on CONFIGURATION-415:
--------------------------------------------

Thanks for spotting this, and thanks to Jörg for the reference.

So, after reading this document, the best solution seems to be to replace the code of the {{fileFromURL()}} method by the content of the {{FileUtils.toFile()}} method.

> ConfigurationUtils.fileFromURL mangles files with '+' (plus sign) in the name
> -----------------------------------------------------------------------------
>
>                 Key: CONFIGURATION-415
>                 URL: https://issues.apache.org/jira/browse/CONFIGURATION-415
>             Project: Commons Configuration
>          Issue Type: Bug
>    Affects Versions: 1.6
>            Reporter: Brian Stiles
>         Attachments: FileFromUrlTest.java
>
>
> Attached is a sample program that demonstrates the problem.  The following is the method in ConfigurationUtils in question:
> public static File fileFromURL(URL url)
> {
> ...
>         return new File(URLDecoder.decode(url.getPath()));
> ...
> }
> URLDecoder (poorly named) decodes data encoded in the application/x-www-form-urlencoded MIME format.  This format is commonly used to encode HTML form data.  It is not intended for encoding URLs, though the formats are similar.
> The operative difference is that the MIME format allows the use of the plus sign ('+') to represent spaces, whereas URLs must have spaces hex encoded ('%20').  Files may have plus signs in the name, and therefore, decoding the plus sign as a space produces a different path.
> See attached code demonstrating the problem.
> Reference:  http://www.w3.org/MarkUp/html-spec/html-spec_8.html#SEC8.2.1
> and http://www.ietf.org/rfc/rfc1738.txt

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Resolved: (CONFIGURATION-415) ConfigurationUtils.fileFromURL mangles files with '+' (plus sign) in the name

Posted by "Oliver Heger (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/CONFIGURATION-415?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Oliver Heger resolved CONFIGURATION-415.
----------------------------------------

    Fix Version/s: 1.7
       Resolution: Fixed

Fixed in subversion in revision 949393. The code in ConfigurationUtils.fileFromURL() was replaced by code from the FileUtils class of Commons IO.

> ConfigurationUtils.fileFromURL mangles files with '+' (plus sign) in the name
> -----------------------------------------------------------------------------
>
>                 Key: CONFIGURATION-415
>                 URL: https://issues.apache.org/jira/browse/CONFIGURATION-415
>             Project: Commons Configuration
>          Issue Type: Bug
>    Affects Versions: 1.6
>            Reporter: Brian Stiles
>            Assignee: Oliver Heger
>             Fix For: 1.7
>
>         Attachments: FileFromUrlTest.java
>
>
> Attached is a sample program that demonstrates the problem.  The following is the method in ConfigurationUtils in question:
> public static File fileFromURL(URL url)
> {
> ...
>         return new File(URLDecoder.decode(url.getPath()));
> ...
> }
> URLDecoder (poorly named) decodes data encoded in the application/x-www-form-urlencoded MIME format.  This format is commonly used to encode HTML form data.  It is not intended for encoding URLs, though the formats are similar.
> The operative difference is that the MIME format allows the use of the plus sign ('+') to represent spaces, whereas URLs must have spaces hex encoded ('%20').  Files may have plus signs in the name, and therefore, decoding the plus sign as a space produces a different path.
> See attached code demonstrating the problem.
> Reference:  http://www.w3.org/MarkUp/html-spec/html-spec_8.html#SEC8.2.1
> and http://www.ietf.org/rfc/rfc1738.txt

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.