Skip to content

Commit 74dd1f9

Browse files
committed
U4-2635 Skip already-checked part of source input
1 parent 86f7d79 commit 74dd1f9

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/Umbraco.Core/StringExtensions.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1191,10 +1191,11 @@ public static string ToSafeFileName(this string text, CultureInfo culture)
11911191
/// <returns>Updated string</returns>
11921192
public static string Replace(this string source, string oldString, string newString, StringComparison stringComparison)
11931193
{
1194-
int index;
1194+
// Initialised to zero so it can be used as startIndex on first iteration.
1195+
int index = 0;
11951196

1196-
// Determine if there are any matches left in source.
1197-
while((index = source.IndexOf(oldString, stringComparison)) >= 0)
1197+
// Determine if there are any matches left in source, starting from last found match.
1198+
while((index = source.IndexOf(oldString, index, stringComparison)) >= 0)
11981199
{
11991200
// Remove the old text.
12001201
source = source.Remove(index, oldString.Length);

0 commit comments

Comments
 (0)