Merge pull request #2702 from akoeplinger/bug-38933
authorJoão Matos <joao@tritao.eu>
Tue, 1 Mar 2016 10:10:59 +0000 (10:10 +0000)
committerJoão Matos <joao@tritao.eu>
Tue, 1 Mar 2016 10:10:59 +0000 (10:10 +0000)
[System.Security] Fix CryptographicException from ProtectedData.Protect with multiple threads

mcs/class/corlib/System/TimeZoneInfo.cs
mcs/class/corlib/Test/System/TimeZoneInfoTest.cs

index 81675b16232b327fa9b2cd836eda14b6441f616e..466678053574bb701b9ca5cc44b4b37b0eb4d7b1 100644 (file)
@@ -295,7 +295,8 @@ namespace System
                        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);
                }
index 3bb464fe83d588485c10b81541e2bf52236748a8..ec5d1c975b39e243a2115751a63e6a154f8a848d 100644 (file)
@@ -782,6 +782,15 @@ namespace MonoTests.System
                                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]