U4-2635 Skip past replaced word when checking
Avoids infinite loop if search and replacement are equal
This commit is contained in:
@@ -83,6 +83,9 @@ namespace Umbraco.Tests.CoreStrings
|
||||
[TestCase("Hello this is my string", "hello", "replaced", "replaced this is my string", StringComparison.CurrentCultureIgnoreCase)]
|
||||
[TestCase("Hello this is hello my string", "hello", "replaced", "replaced this is replaced my string", StringComparison.CurrentCultureIgnoreCase)]
|
||||
[TestCase("Hello this is my string", "nonexistent", "replaced", "Hello this is my string", StringComparison.CurrentCultureIgnoreCase)]
|
||||
[TestCase("Hellohello this is my string", "hello", "replaced", "replacedreplaced this is my string", StringComparison.CurrentCultureIgnoreCase)]
|
||||
// Ensure replacing with the same string doesn't cause infinite loop.
|
||||
[TestCase("Hello this is my string", "hello", "hello", "hello this is my string", StringComparison.CurrentCultureIgnoreCase)]
|
||||
public void ReplaceWithStringComparison(string input, string oldString, string newString, string shouldBe, StringComparison stringComparison)
|
||||
{
|
||||
var replaced = input.Replace(oldString, newString, stringComparison);
|
||||
|
||||
Reference in New Issue
Block a user