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
The code is using some string operation like IndexOf without passing the StringComparison option. by default doing that the operation will assume want linguistic behavior. This can produce some surprises and wrong results in some situations. for example
search for "[" inside the string. this operation can succeed in some cases even the source string not including [ character. Like if the user current culture is set to Thai culture. The fix for such case can be either do the search using a character instead of string like IndexOf('[') or passing StringComparison parameter like IndexOf("[", StringComparison.Ordinal)
The string operations in the code should always produce the desired result and be protected from surprising behaviors.
Complete this.
Is this a regression from the previous version?
No but the behavior can cause serious problems for the library users.
Reproducibility
This is an important section. Read it carefully. Failure to do so will cause a 'RTFM' comment.
Just set the current culture to Thai and run some code depends on the code path using such string operations.
Code to reproduce problem:
publicvoidMain(){
CultureInfo.CurrentCulture = CultureInfo.GetCultureInfo("th-th");// call your library here with operation exercising the code path using such string operation}
I attached a sample spreadsheet. (You can drag files on to this issue)
The text was updated successfully, but these errors were encountered:
Related: culture to the workbook #1367. We should use some sensible culture or the workbook culture for all string operations.
Notes:
Use sensible culture (probably ordinal, but be sure to think it through/case-by-case)
Some might methods might be missing StringComparison parameter be missing (we target netstandard 2.0), enable net6 target during PR development to find missing methods. Don't include the target in the PR. Create extension methods (see Remarks for string.Contains)
In a server scenario it could be useful (when creating or opening a workbook) to specify the appropriate culture as derived (for example) from a user's / client's properties associated with the current request.
Read and complete the full issue template
Do not randomly delete sections. They are here for a reason.
Do you want to request a feature or report a bug?
Did you test against the latest CI build?
If you answered
No
, please test with the latest development build first.Version of ClosedXML
latest.
What is the current behavior?
The code is using some string operation like IndexOf without passing the StringComparison option. by default doing that the operation will assume want linguistic behavior. This can produce some surprises and wrong results in some situations. for example
ClosedXML/ClosedXML/Excel/XLWorkbook_Load.cs
Line 1249 in 78150ef
[
character. Like if the user current culture is set to Thai culture. The fix for such case can be either do the search using a character instead of string likeIndexOf('[')
or passingStringComparison
parameter likeIndexOf("[", StringComparison.Ordinal)
Maybe will be a good idea enable the analyzers listed in https://docs.microsoft.com/en-us/dotnet/fundamentals/code-analysis/quality-rules/globalization-warnings?view=vs-2022 on your codebase.
What is the expected behavior or new feature?
The string operations in the code should always produce the desired result and be protected from surprising behaviors.
Complete this.
Is this a regression from the previous version?
No but the behavior can cause serious problems for the library users.
Reproducibility
This is an important section. Read it carefully. Failure to do so will cause a 'RTFM' comment.
Just set the current culture to Thai and run some code depends on the code path using such string operations.
Code to reproduce problem:
The text was updated successfully, but these errors were encountered: