[System.Security] Fix CryptographicException from ProtectedData.Protect with multiple threads
var Istart = 0;
while (Istart < str.Length && !char.IsLetterOrDigit(str[Istart])) Istart++;
var Iend = str.Length - 1;
- while (Iend > Istart && !char.IsLetterOrDigit(str[Iend])) Iend--;
+ while (Iend > Istart && !char.IsLetterOrDigit(str[Iend]) && str[Iend] != ')') // zone name can include parentheses like "Central Standard Time (Mexico)"
+ Iend--;
return str.Substring (Istart, Iend-Istart+1);
}
var timeZones = (global::System.Collections.ObjectModel.ReadOnlyCollection<TimeZoneInfo>) method.Invoke (null, null);
Assert.IsTrue (timeZones.Count > 0, "GetSystemTimeZones should not return an empty collection.");
}
+
+ [Test]
+ public void WindowsRegistryTimezoneWithParentheses ()
+ {
+ var method = (MethodInfo) typeof (TimeZoneInfo).GetMember ("TrimSpecial", MemberTypes.Method, BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic)[0];
+
+ var name = method.Invoke (null, new object [] { " <---> Central Standard Time (Mexico) ||<<>>" });
+ Assert.AreEqual (name, "Central Standard Time (Mexico)", "#1");
+ }
}
[TestFixture]