alexreinert / ARSoft.Tools.Net

This project contains a complete managed .Net SPF validation, SenderID validation and a dns client and dns server implementation written in C#.
Apache License 2.0
166 stars 81 forks source link

Problems with Turkish character set #36

Open karoly-arnhoffer opened 3 months ago

karoly-arnhoffer commented 3 months ago

Dear Alex,

We use your library to check SPF records in emails.

My colleague found a place where the library perform a case insensitive match for the word ‘include’ & ‘Include’ (by converting the word Include to lowercase). This works fine in Western European character sets, but fails in Turkish.

The verb here should be include (which it is when we run the tool locally on computers with Western European character sets, but on computers with Turkish character sets it becomes ‘Unknown’):

image

This means it does not expand some SPF records and the check fails.

Could you please verify or reproduce this? If yes, could you please fix this for us? Thank you!

zsolt-opswat commented 3 months ago

Hi @alexreinert

We have managed to reproduce the issue and found its root cause. The problem occurs in the EnumHelper when the static constructor fills the _values field with a lowercase variant at line 44. This particular issue happened with SpfMechanismType.Include which after the culture-sensitive ToLower call became ınclude in Turkish culture. This did not match the received include from the TxtRecord and became unknown as shown in the above picture.

see attachment: image

Changing the conversion to use invariant culture seems to fix the issue. If you accept PR on this project we'd happily submit a small one addressing this particular issue.

alexreinert commented 3 months ago

Sorry, but for legal reasons I can not accept PRs. But I will provide a fix soon.

zsolt-opswat commented 3 months ago

I understand. We appreciate your support!

alexreinert commented 3 months ago

Should be fixed in version 3.6.1