[PR #8951] Explicitly setting DOTNET_SYSTEM_GLOBALIZATION_INVARIANT=0 in Dockerfiles #11920

Closed
opened 2026-02-07 06:46:53 +03:00 by OVERLORD · 0 comments
Owner

Original Pull Request: https://github.com/jellyfin/jellyfin/pull/8951

State: closed
Merged: No


Context

https://github.com/jellyfin/jellyfin/pull/6629 implicitly disabled DOTNET_SYSTEM_GLOBALIZATION_INVARIANT in docker images. However, by only commenting out =1 and not explicitly setting =0, there exists at least one side effect of this.

Detected side effect

  1. Using the Jellyfin Docker image
  2. Install dotnet-script and generate a script with the following code from StringExtensions.cs:
using System;
using System.Globalization;
using System.Text;
using System.Text.RegularExpressions;

static readonly Regex _nonConformingUnicode = new Regex("([\ud800-\udbff](?![\udc00-\udfff]))|((?<![\ud800-\udbff])[\udc00-\udfff])|(\ufffd)");

public static string RemoveDiacritics(this string text)
{
    string withDiactritics = _nonConformingUnicode
	.Replace(text, string.Empty)
	.Normalize(NormalizationForm.FormD);

    var withoutDiactritics = new StringBuilder();
    foreach (char c in withDiactritics)
    {
	UnicodeCategory uc = CharUnicodeInfo.GetUnicodeCategory(c);
	if (uc != UnicodeCategory.NonSpacingMark)
	{
	    withoutDiactritics.Append(c);
	}
    }

    return withoutDiactritics.ToString().Normalize(NormalizationForm.FormC);
}

Console.WriteLine(RemoveDiacritics("é"));
  1. Run this script both with and without DOTNET_SYSTEM_GLOBALIZATION_INVARIANT:
# DOTNET_SYSTEM_GLOBALIZATION_INVARIANT=0 /root/.dotnet/tools/dotnet-script helloworld.csx 
e
# DOTNET_SYSTEM_GLOBALIZATION_INVARIANT=1 /root/.dotnet/tools/dotnet-script helloworld.csx 
é

Changes

Explicitly setting DOTNET_SYSTEM_GLOBALIZATION_INVARIANT=0

Fixes

This change ensures that the unit tests we see in https://github.com/jellyfin/jellyfin/blob/master/tests/Jellyfin.Extensions.Tests/StringExtensionsTests.cs#L12 actually behave the same way in deployed Docker images. Otherwise the CleanName field in library.db contains accents, resulting in false negative searches for titles that actually contain diacritics.

**Original Pull Request:** https://github.com/jellyfin/jellyfin/pull/8951 **State:** closed **Merged:** No --- # Context https://github.com/jellyfin/jellyfin/pull/6629 implicitly disabled DOTNET_SYSTEM_GLOBALIZATION_INVARIANT in docker images. However, by only commenting out `=1` and not explicitly setting `=0`, there exists at least one side effect of this. ## Detected side effect 1. Using the [Jellyfin Docker image](https://hub.docker.com/layers/jellyfin/jellyfin/20221223.2-unstable/images/sha256-bd807f9aa0a0251bd537f30ae5973a9a7d80d1284529e62d59826098bc46f217?context=explore) 2. Install `dotnet-script` and generate a script with the following code from [StringExtensions.cs](https://github.com/jellyfin/jellyfin/blob/master/src/Jellyfin.Extensions/StringExtensions.cs#L22): ```C# using System; using System.Globalization; using System.Text; using System.Text.RegularExpressions; static readonly Regex _nonConformingUnicode = new Regex("([\ud800-\udbff](?![\udc00-\udfff]))|((?<![\ud800-\udbff])[\udc00-\udfff])|(\ufffd)"); public static string RemoveDiacritics(this string text) { string withDiactritics = _nonConformingUnicode .Replace(text, string.Empty) .Normalize(NormalizationForm.FormD); var withoutDiactritics = new StringBuilder(); foreach (char c in withDiactritics) { UnicodeCategory uc = CharUnicodeInfo.GetUnicodeCategory(c); if (uc != UnicodeCategory.NonSpacingMark) { withoutDiactritics.Append(c); } } return withoutDiactritics.ToString().Normalize(NormalizationForm.FormC); } Console.WriteLine(RemoveDiacritics("é")); ``` 3. Run this script both with and without `DOTNET_SYSTEM_GLOBALIZATION_INVARIANT`: ``` # DOTNET_SYSTEM_GLOBALIZATION_INVARIANT=0 /root/.dotnet/tools/dotnet-script helloworld.csx e # DOTNET_SYSTEM_GLOBALIZATION_INVARIANT=1 /root/.dotnet/tools/dotnet-script helloworld.csx é ``` # Changes Explicitly setting `DOTNET_SYSTEM_GLOBALIZATION_INVARIANT=0` # Fixes This change ensures that the unit tests we see in https://github.com/jellyfin/jellyfin/blob/master/tests/Jellyfin.Extensions.Tests/StringExtensionsTests.cs#L12 actually behave the same way in deployed Docker images. Otherwise the `CleanName` field in library.db contains accents, resulting in false negative searches for titles that actually contain diacritics.
OVERLORD added the pull-request label 2026-02-07 06:46:53 +03:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/jellyfin#11920