#19235: Fixing possible multi-threading issues when striping characters from string.

This happened to be the reason for scripts/stylesheets not being included in the correct order sometimes. Char array passed might get corrupted when multiple string replacements were done in parallel, making the resulting string incorrect.
This method is most commonly used during shape name and alternate generation for resources, hence the issues.

Work Item: 19235
This commit is contained in:
Piotr Szmyd
2013-08-20 23:00:53 +02:00
parent ee526030f8
commit b95ce0cc7d

View File

@@ -215,13 +215,12 @@ namespace Orchard.Utility.Extensions {
return subject;
}
Array.Sort(stripped);
var result = new char[subject.Length];
var cursor = 0;
for (var i = 0; i < subject.Length; i++) {
char current = subject[i];
if (Array.BinarySearch(stripped, current) < 0) {
if (Array.IndexOf(stripped, current) < 0) {
result[cursor++] = current;
}
}