irgaly / android-remove-unused-resources-plugin

A gradle plugin to remove unused android resources by Android Lint results xml file.
https://plugins.gradle.org/plugin/io.github.irgaly.remove-unused-resources
Other
29 stars 1 forks source link

FIX: some characters are modified #15

Closed irgaly closed 2 years ago

irgaly commented 2 years ago

example:

<stirng name="foo">foo > bar</string>

will be xml escaped

<stirng name="foo">foo &gt; bar</string>
irgaly commented 2 years ago
<string name="empty"></string>

will be

<string name="empty"/>
irgaly commented 2 years ago

attributes

before after
&#{unicode}; {unicode decoded string}
&#x0A; &#10;
&#x0D; &#13;
&gt; &gt;
&lt; &lt;
> &gt;
&amp; &amp;
&apos; '

content

before after
> &gt;
&gt; &gt;
&#{unicode}; {unicode decoded string}
&#x0D; &#13;
&lt; &lt;
&amp; &amp;
&apos; '
irgaly commented 2 years ago

The only way to preserve original text in javax.xml is using StAX Parser.

ref: https://stackoverflow.com/a/14748821/13403244 https://www.bold.ne.jp/engineer-club/java-xml-read#-XMLStreamReader

irgaly commented 2 years ago

StAX parser's IS_REPLACING_ENTITY_REFERENCES can not prevents special characters replacement...

irgaly commented 2 years ago

I'll fix this problem with StAX parser and event location + original text location.

irgaly commented 2 years ago

release in v1.1.0