Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Prerequisites
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 totrue
(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 forRequestHandler: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:"try"
and"true"
should both yield ASCII conversion."false"
should retain the current behaviour (same as not addingRequestHandler:ConvertFileNamesToAscii
to app settings).