Skip to content

Commit 7bc389c

Browse files
committed
Fix Term is upercase
1 parent 3396cc3 commit 7bc389c

File tree

3 files changed

+17
-3
lines changed

3 files changed

+17
-3
lines changed

src/Nager.EmailAuthentication.UnitTest/SpfRecordParserTest/FragmentParser/BasicTest.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,5 +73,17 @@ public void Should_Parse_Spf_With_Multiple_Ip4_And_Include()
7373
Assert.IsNotNull(spfDataFragment.SpfTerms);
7474
Assert.AreEqual(7, spfDataFragment.SpfTerms.Length);
7575
}
76+
77+
[TestMethod]
78+
public void Should_Parse_Spf_With_Ip4_Uppercase()
79+
{
80+
var spf = "v=spf1 IP4:155.56.66.96 IP4:155.56.66.102/31 -all";
81+
var isSuccessful = SpfRecordDataFragmentParserV1.TryParse(spf, out var spfDataFragment);
82+
83+
Assert.IsTrue(isSuccessful);
84+
Assert.IsNotNull(spfDataFragment);
85+
Assert.IsNotNull(spfDataFragment.SpfTerms);
86+
Assert.AreEqual(3, spfDataFragment.SpfTerms.Length);
87+
}
7688
}
7789
}

src/Nager.EmailAuthentication/FragmentParsers/SpfRecordDataFragmentParserV1.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ public static bool TryParse(
9090

9191
foreach (var mechanismType in mechanismTypes)
9292
{
93-
if (!value.StartsWith(mechanismType.Key))
93+
if (!value.StartsWith(mechanismType.Key, StringComparison.OrdinalIgnoreCase))
9494
{
9595
continue;
9696
}
@@ -120,7 +120,7 @@ public static bool TryParse(
120120

121121
foreach (var modifierType in modifierTypes)
122122
{
123-
if (!value.StartsWith(modifierType.Key))
123+
if (!value.StartsWith(modifierType.Key, StringComparison.OrdinalIgnoreCase))
124124
{
125125
continue;
126126
}
@@ -146,6 +146,8 @@ public static bool TryParse(
146146
}
147147
}
148148

149+
//Failure found no match
150+
149151
inputSpan = inputSpan[(nextIndexOfDelimiter + 1)..];
150152
}
151153

src/Nager.EmailAuthentication/Nager.EmailAuthentication.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020

2121
<TargetFrameworks>net8.0;net9.0</TargetFrameworks>
2222

23-
<Version>4.0.0</Version>
23+
<Version>4.0.1</Version>
2424
</PropertyGroup>
2525

2626
<ItemGroup>

0 commit comments

Comments
 (0)