commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Oliver Heger (JIRA)" <>
Subject [jira] Commented: (CONFIGURATION-415) ConfigurationUtils.fileFromURL mangles files with '+' (plus sign) in the name
Date Thu, 20 May 2010 15:51:53 GMT


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:
>             Project: Commons Configuration
>          Issue Type: Bug
>    Affects Versions: 1.6
>            Reporter: Brian Stiles
>         Attachments:
> 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:
> and

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

View raw message