Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ASCII file name conversion #17580

Merged
merged 1 commit into from
Nov 26, 2024
Merged

Conversation

kjac
Copy link
Contributor

@kjac kjac commented Nov 19, 2024

Prerequisites

  • I have added steps to test this contribution in the description below

If there's an existing issue for this PR then this fixes #15939

Description

#15939 describes a difference between how content URL segments and media file names are encoded. However, the issue description is slightly off point - and as it happens, the difference is a feature 😄 albeit a somewhat confusing one, specially when char replacements are added to the mix.

Starting with the latter, with RequestHandler:EnableDefaultCharReplacements set to true (which is the default), specific characters to be replaced with URL friendly alternatives (e.g. "å" is replaced by "aa" in the default configuration). These char replacements apply to both URL segments and file paths.

On top of the char replacements we have RequestHandler:ConvertUrlsToAscii, which is set to "try" by default. This setting only affects the URL segment encoding, and causes all non-ASCII chars to be replaced by an ASCII char.

As a result, a content page named "ÅÅ Øø Ææ Ã" will yield the URL segment "aaaa-oeoe-aeae-a", whereas uploading file named "ÅÅ Øø Ææ Ã.png" will yield the media file name "aaaa-oeoe-aeae-ã.png".

At this time there is no way to obtain an ASCII encoded file name, and that is what this PR addresses: It adds the option to configure RequestHandler:ConvertFileNamesToAscii as the media file name counterpart to content URL segments.

The new configuration works the same as RequestHandler:ConvertUrlsToAscii. It accepts the values "try", "true" and "false". To retain the current functionality, the default value for RequestHandler:ConvertFileNamesToAscii is "false"

Future considerations

In reality, we would actually like to have file names ASCII encoded by default. We will likely change the default behaviour of RequestHandler:ConvertFileNamesToAscii in an upcoming major release. Keep an eye out for the announcements 😄

Testing this PR

Start by testing without adding RequestHandler:ConvertFileNamesToAscii to app settings. Verify that the current behaviour persists (char conversions are applied to file names but ASCII conversion is not).

Add RequestHandler:ConvertFileNamesToAscii to app settings:

  • the config values "try" and "true" should both yield ASCII conversion.
  • the config value "false" should retain the current behaviour (same as not adding RequestHandler:ConvertFileNamesToAscii to app settings).

@Zeegaan
Copy link
Member

Zeegaan commented Nov 26, 2024

Looks good, tests good 🚀

@Zeegaan Zeegaan merged commit 4590739 into v13/dev Nov 26, 2024
16 checks passed
@Zeegaan Zeegaan deleted the v13/fix/15939-ascii-file-names branch November 26, 2024 10:26
@kjac
Copy link
Contributor Author

kjac commented Nov 27, 2024

Cherry-picked for V15.1 RC

kjac added a commit that referenced this pull request Nov 27, 2024
kjac added a commit that referenced this pull request Nov 27, 2024
(cherry picked from commit 4590739)
(cherry picked from commit 3d1505d)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants