diff options
author | David KarlasĖ <david.karlas@microsoft.com> | 2019-09-07 16:55:03 +0300 |
---|---|---|
committer | Marek Safar <marek.safar@gmail.com> | 2019-09-09 11:05:57 +0300 |
commit | 13391beeed5d4c8d2a98f56a8b9592e489966add (patch) | |
tree | aea036069a22df177b4803666b013e76bcf5d658 /mcs/class/System.Xaml | |
parent | d81ec884066bc81ffc1fc8f8116ff31428ccfe6f (diff) |
Fix Xaml reader to parse escaped values correctly
Diffstat (limited to 'mcs/class/System.Xaml')
-rw-r--r-- | mcs/class/System.Xaml/System.Xaml/XamlXmlReader.cs | 27 | ||||
-rwxr-xr-x | mcs/class/System.Xaml/Test/System.Xaml/XamlXmlReaderTest.cs | 7 |
2 files changed, 23 insertions, 11 deletions
diff --git a/mcs/class/System.Xaml/System.Xaml/XamlXmlReader.cs b/mcs/class/System.Xaml/System.Xaml/XamlXmlReader.cs index bf855511f61..f025676ecb9 100644 --- a/mcs/class/System.Xaml/System.Xaml/XamlXmlReader.cs +++ b/mcs/class/System.Xaml/System.Xaml/XamlXmlReader.cs @@ -317,18 +317,23 @@ namespace System.Xaml // FIXME: is this rule correct? var v = pair.Value; if (!String.IsNullOrEmpty (v) && v [0] == '{') { - var pai = ParsedMarkupExtensionInfo.Parse (v, xaml_namespace_resolver, sctx); - yield return Node (XamlNodeType.StartObject, pai.Type); - foreach (var xepair in pai.Arguments) { - yield return Node (XamlNodeType.StartMember, xepair.Key); - if (xepair.Value is List<string>) - foreach (var s in (List<string>) xepair.Value) - yield return Node (XamlNodeType.Value, s); - else - yield return Node (XamlNodeType.Value, xepair.Value); - yield return Node (XamlNodeType.EndMember, xepair.Key); + if (v.Length > 1 && v [1] == '}') { + //Escaped value + yield return Node (XamlNodeType.Value, v.Substring (2)); + } else { + var pai = ParsedMarkupExtensionInfo.Parse (v, xaml_namespace_resolver, sctx); + yield return Node (XamlNodeType.StartObject, pai.Type); + foreach (var xepair in pai.Arguments) { + yield return Node (XamlNodeType.StartMember, xepair.Key); + if (xepair.Value is List<string>) + foreach (var s in (List<string>) xepair.Value) + yield return Node (XamlNodeType.Value, s); + else + yield return Node (XamlNodeType.Value, xepair.Value); + yield return Node (XamlNodeType.EndMember, xepair.Key); + } + yield return Node (XamlNodeType.EndObject, pai.Type); } - yield return Node (XamlNodeType.EndObject, pai.Type); } else yield return Node (XamlNodeType.Value, pair.Value); diff --git a/mcs/class/System.Xaml/Test/System.Xaml/XamlXmlReaderTest.cs b/mcs/class/System.Xaml/Test/System.Xaml/XamlXmlReaderTest.cs index b2d90b00e0c..5e58267cc9a 100755 --- a/mcs/class/System.Xaml/Test/System.Xaml/XamlXmlReaderTest.cs +++ b/mcs/class/System.Xaml/Test/System.Xaml/XamlXmlReaderTest.cs @@ -720,6 +720,13 @@ namespace MonoTests.System.Xaml Read_ContentPropertyContainer (r); } + [Test] + public void EscapedValue () + { + var exception = (Exception)XamlServices.Load(new StringReader("<Exception xmlns=\"clr-namespace:System;assembly=mscorlib\" HelpLink=\"{}{123}\" />")); + Assert.AreEqual ("{123}", exception.HelpLink); + } + #region non-common tests [Test] public void Bug680385 () |