White Space Management removing Double Spaces in file names

Description

When whitespace management is turned on in Admin a double space is converted to a single space. This is a a problem when dealing with files names that you do not control the naming.

Example: Reading file names using cfdirectory and then listing them to a page and providing the user a link to download.

A link in my code named <a href="user[:space:][:space:]image.jpg">User Image</a> would be changed to rewritten to <a href="user[:space:]image.jpg">User Image</a> in the code therefore causing a 404 on the server when clicked.

Environment

None

Activity

Igal Sapir 
5 July 2017 at 16:42

from RFC-1738: https://www.ietf.org/rfc/rfc1738.txt

The space character is unsafe because significant spaces may disappear and
insignificant spaces may be introduced when URLs are transcribed or
typeset or subjected to the treatment of word-processing programs.

...

All unsafe characters must always be encoded within a URL.

Former user 
5 July 2017 at 16:11

Disable whitespace is a bad idea and the simple one is a bad idea too.

I disagree about your statement that you cannot use unencoded spaces. <a href="/path / to /a file/some space file.jpg">Download</a> will work if it is in your HTML and if that path is correct. The browser will encode the spaces for you and it works on all modern browsers. While you SHOULD encode your file paths they are not always encoded and it is possible for them to work.

I still feel like the intelligent whitespace management should be more intelligent.

Igal Sapir 
5 July 2017 at 15:48

You can disable the Whitespace Management, or use the Simple one.

All URLs, in links or otherwise must be URL encoded. You can't use unencoded spaces in URLs and blame the systems or the specifications.

Former user 
5 July 2017 at 14:39
(edited)

I agree that we should be not allow double or more spaces on our end. I do feel that the whitespace management may need to be smarter (when it is selected) and NOT do white space removal inside of the <a> and <img> tags. This would solve the problem for everyone using dynamic file names that the user controls during upload in CMS system or file management systems.

Igal Sapir 
19 June 2017 at 08:10
(edited)

p.s. if you replace all the spaces with the plus sign when rendering the links then you probably don't need to do anything else, e.g.

as the plus symbol will be parsed as a space.

what you should do, though, is URLEncode() all your links.

Won't Fix

Details

Assignee

Reporter

Priority

New Issue warning screen

Before you create a new Issue, please post to the mailing list first https://dev.lucee.org

Once the issue has been verified, one of the Lucee team will ask you to file an issue

Affects versions

Created 16 June 2017 at 17:05
Updated 5 July 2017 at 16:42
Resolved 5 July 2017 at 16:42