From 79744f61b935279d9a7fa6efd7bb840a03364149 Mon Sep 17 00:00:00 2001 From: Jonathan Pobst Date: Tue, 26 Oct 2021 13:36:26 -0500 Subject: [PATCH] [generator] Fix for fixing invalid annotation XML. (#897) Fixes: https://github.com/xamarin/java.interop/issues/883 Due to invalid XML provided in Google's `annotations.zip` file, we run it through the more forgiving `HtmlAgilityPack` (4073f3ec) to attempt to fix it to valid XML. However, given this snippet: The invalid unescaped `<` and `>` characters in the `//item/@name` attribute seem to tell `HtmlAgilityPack` not to expect any attribute strings to be properly escaped. Thus when it gets to the `//val/@val` attributes, it treats `"` as unescaped as well, thinking we want to value to be the literal string `"""`. When it writes out the valid XML, it realizes it needs to escape the ampersand, and writes out `&quot;`, which breaks our usage of these annotations. The fix is to "unescape" every `"` to a `"` so that it will be escaped correctly when saved as valid XML. --- .../AndroidAnnotationsSupport.cs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/Xamarin.Android.Tools.AnnotationSupport/AndroidAnnotationsSupport.cs b/src/Xamarin.Android.Tools.AnnotationSupport/AndroidAnnotationsSupport.cs index ef6414667..05641e280 100644 --- a/src/Xamarin.Android.Tools.AnnotationSupport/AndroidAnnotationsSupport.cs +++ b/src/Xamarin.Android.Tools.AnnotationSupport/AndroidAnnotationsSupport.cs @@ -70,6 +70,8 @@ static Stream FixAnnotationXML (Stream s) if (doc.DocumentNode.FirstChild.InnerHtml.StartsWith ("