Use a regex to filter our invalid culture codes rather than relying on the culture being installed on the operating system #19821
+53
−11
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
Addresses: #19817
Description
The linked issue flags a security hardening introduced to ensure that the culture code provided in the preview URL is valid. We did this by verifying that the culture code provided one can be used to construct a
CultureInfo
. However this failed unnecessarily for culture codes that were valid syntactically but not installed on the operation system and exposed by .NET.Given we have this to prevent XSS vulnerabilities, it would seem enough to verify the culture code contains only valid characters. So that's what this PR does.
Testing
Preview a page in Umbraco and verify that the provided culture code is accepted and the preview shown.
Manipulate the culture code provided in the querystring to create an invalid one and verify that an exception is thrown.
Release
Needs to be merged/re-applied to Umbraco 16.