Skip to content

Commit d9e9264

Browse files
committed
Fix off-by-one string indexing in constraint checking
Also change string comparison type to `StringComparison.Ordinal`, which should be the correct type according to https://docs.microsoft.com/en-us/dotnet/standard/base-types/best-practices-strings.
1 parent 3894ce1 commit d9e9264

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

ModuleManager/Extensions/StringExtensions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public static bool Contains(this string str, string value, out int index)
3030
if (str == null) throw new ArgumentNullException(nameof(str));
3131
if (value == null) throw new ArgumentNullException(nameof(value));
3232

33-
index = str.IndexOf(value, StringComparison.CurrentCultureIgnoreCase);
33+
index = str.IndexOf(value, StringComparison.Ordinal);
3434
return index != -1;
3535
}
3636
}

ModuleManager/MMPatchLoader.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1548,7 +1548,7 @@ public static bool CheckConstraints(ConfigNode node, string constraints)
15481548
string remainingConstraints = "";
15491549
if (constraints.Contains(":HAS[", out int hasStart))
15501550
{
1551-
hasStart += 4;
1551+
hasStart += 5;
15521552
remainingConstraints = constraints.Substring(hasStart, constraintList[0].LastIndexOf(']') - hasStart);
15531553
constraints = constraints.Substring(0, hasStart - 5);
15541554
}

0 commit comments

Comments
 (0)