Commit 79744f6
authored
[generator] Fix for fixing invalid annotation XML. (dotnet#897)
Fixes: dotnet#883
Due to invalid XML provided in Google's `annotations.zip` file, we
run it through the more forgiving `HtmlAgilityPack` (4073f3e) to
attempt to fix it to valid XML.
However, given this snippet:
<item name="android.accounts.AccountManager android.accounts.AccountManagerFuture<android.os.Bundle> addAccount(java.lang.String, java.lang.String, java.lang.String[], android.os.Bundle, android.app.Activity, android.accounts.AccountManagerCallback<android.os.Bundle>, android.os.Handler)">
<annotation name="androidx.annotation.RequiresPermission">
<val name="value" val=""android.permission.MANAGE_ACCOUNTS"" />
<val name="apis" val=""..22"" />
</annotation>
</item>
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.1 parent 220b87f commit 79744f6
File tree
1 file changed
+14
-0
lines changed- src/Xamarin.Android.Tools.AnnotationSupport
1 file changed
+14
-0
lines changedLines changed: 14 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
70 | 70 | | |
71 | 71 | | |
72 | 72 | | |
| 73 | + | |
| 74 | + | |
73 | 75 | | |
74 | 76 | | |
75 | 77 | | |
| |||
86 | 88 | | |
87 | 89 | | |
88 | 90 | | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
89 | 103 | | |
90 | 104 | | |
91 | 105 | | |
| |||
0 commit comments