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

RomanNumeralExtensions.FromRoman incorrectly handles Latin Small Letter Dotless I #1507

Closed
stephentoub opened this issue May 28, 2024 · 0 comments · Fixed by #1508
Closed

Comments

@stephentoub
Copy link
Contributor

The regex allows it through (as it's using current culture with ignore case) but the dictionary doesn't contain an entry that maps to it (as it's using ordinal ignore case), and thus the dictionary lookup throws:

using Humanizer;
using System.Globalization;

CultureInfo.CurrentCulture = new CultureInfo("tr-TR");
Console.WriteLine(RomanNumeralExtensions.FromRoman("\u0131"));

results in:

Unhandled exception. System.Collections.Generic.KeyNotFoundException: The given key 'i' was not present in the dictionary.
   at System.Collections.Generic.Dictionary`2.get_Item(TKey key)
   at Humanizer.RomanNumeralExtensions.FromRoman(ReadOnlySpan`1 input) in /_/src/Humanizer/RomanNumeralExtensions.cs:line 95
   at Humanizer.RomanNumeralExtensions.FromRoman(String input) in /_/src/Humanizer/RomanNumeralExtensions.cs:line 71
   at Program.<Main>$(String[] args)

My guess is the intent was for the regex to be using invariant culture, such that only i and I are permitted, and not ı or İ.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant