You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
exception on binding WPF BitmapImage and german umlauts are used in file names (dotnet 9.0.0 / windows 11) #111355
public string FullFileName2 { get { return @"\\ps-nas\Temp\products\TestU\testImage.jpg"; } } // --> this works
public string FullFileName2 { get { return @"\\ps-nas\Temp\products\TestÜ\testImage.jpg"; } } // --> this does not work
Expected behavior
german umlauts in filenames should work like in dotnet 8.
Actual behavior
Inner Exception 1:
DirectoryNotFoundException: Could not find a part of the path '\\ps-nas\temp\products\testü\testimage.jpg\Temp\products\TestÜ\testImage.jpg'.
the Image class does not use the provided path an appends something weird. --> the modified file name does not exist --> Exception.
wrong filename:
\\ps-nas\temp\products\testü\testimage.jpg\Temp\products\TestÜ\testImage.jpg
should be:
\\ps-nas\temp\products\testü\testimage.jpg
RestUnicodeNormalized is both checked and set only in ParseRemaining. But this method will be called exactly once if HasUnicode is set, so it will always be false for the one time it's checked.
What I missed is that this helper exists where we will create a partial?? copy of the existing instance:
In this case that means that we've created an instance where the internal strings have already been transformed, but we'll transform them again since we didn't copy the part of the state that tells use we've already done so (hence the duplication). We'll hit debug asserts that assume those code paths are only reachable while in the ctor.
The partial copy could also end up reading flags in a torn state on 32-bit if the existing instnace is being used by other threads.
I added a unittest for this bug to my project and that showed another bug in Visual Studio:
the string is colored incorrect , when a german umlaut is used (brown color instead of blue color).
See red boxes in picture.
Maybe the same bug, but i am not sure.....
[Theory]
[InlineData(@"c:\temp", "file:///c:/temp")]
[InlineData(@"\\ps-nas\Temp\products\TestU\testImage.jpg", "file://ps-nas/Temp/products/TestU/testImage.jpg")]
[InlineData(@"\\ps-nas\Temp\products\TestÜ\testImage.jpg", "file://ps-nas/Temp/products/TestÜ/testImage.jpg")]
[InlineData(@"\\ps-nas\Temp\testÜmage.jpg", "file://ps-nas/Temp/testÜmage.jpg")]
public void RunTest(string param, string expected)
{
Uri bse = new Uri("http://microsoft.com");
Uri rel = new Uri(param);
Uri u = new Uri(bse, rel);
Assert.Equal(rel.ToString(), expected);
Assert.Equal(u.ToString(), expected);
}
As a possible workaround, you can avoid this issue by ensuring that BitmapImage.BaseUri is null (e.g. via a custom IValueConverter). If the base isn't set, your full path won't get mangled.
Activity
dotnet-policy-service commentedon Dec 19, 2024
Tagging subscribers to this area: @dotnet/area-system-io
See info in area-owners.md if you want to be subscribed.
adamsitnik commentedon Jan 13, 2025
Because of that I've moved the issue to WPF.
miloush commentedon Jan 13, 2025
@adamsitnik I am afraid that was a bit premature. Here is a repro not involving WPF:
dotnet-policy-service commentedon Jan 13, 2025
Tagging subscribers to this area: @dotnet/ncl
See info in area-owners.md if you want to be subscribed.
adamsitnik commentedon Jan 13, 2025
@miloush big thanks for catching that!
I've moved it back to dotnet/runtime and added to System.Net area.
The repro:
MihaZupan commentedon Jan 13, 2025
The test case asserts in debug :/
This is a regression from #97579, looks like we have no test coverage for this case:
new Uri(base, relative)In #97579 I stated
What I missed is that this helper exists where we will create a partial?? copy of the existing instance:
runtime/src/libraries/System.Private.Uri/src/System/UriExt.cs
Lines 1052 to 1062 in 812d504
In this case that means that we've created an instance where the internal strings have already been transformed, but we'll transform them again since we didn't copy the part of the state that tells use we've already done so (hence the duplication). We'll hit debug asserts that assume those code paths are only reachable while in the ctor.
The partial copy could also end up reading flags in a torn state on 32-bit if the existing instnace is being used by other threads.
wd72 commentedon Jan 13, 2025
I added a unittest for this bug to my project and that showed another bug in Visual Studio:
the string is colored incorrect , when a german umlaut is used (brown color instead of blue color).
See red boxes in picture.
Maybe the same bug, but i am not sure.....
miloush commentedon Jan 13, 2025
@wd72 that is an unrelated issue, you should file that one through Visual Studio.
MihaZupan commentedon Jan 14, 2025
As a possible workaround, you can avoid this issue by ensuring that
BitmapImage.BaseUriisnull(e.g. via a customIValueConverter). If the base isn't set, your full path won't get mangled.