desword / android-apktool

Automatically exported from code.google.com/p/android-apktool
Other
1 stars 0 forks source link

Ampersand in "<" gets replaced with "&" in plural strings #658

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Create a project (like [1]) that has plurals resources [2].
2. Decode the APK [3] with "apktool.bat d app-debug".
3. Compare the original plurals.xml [4] to the decoded one [5].

What is the expected output? What do you see instead?

I'd expect [4] and [5] to be identical. Instead, [4] has

    <item quantity="one">&lt;b&gt;%d&lt;/b&gt; guide</item>

while [5] has

    <item quantity="one">&amp;lt;b>%d&amp;lt;/b> guide</item>

What version of the product are you using? On what operating system?

Using apktool 1.5.2 on Windows 88 64-bit with Java 7 Update 55.

Please provide any additional information below.

I've also built apktool 2.0.0-RC1 from sources (commit a7b06f1) and observe the 
same error, although the very similar issue #391 is supposed to be fixed in 
version 2.0.0.

[1] https://github.com/sschuberth/sandbox/tree/apktool
[2] 
http://developer.android.com/guide/topics/resources/string-resource.html#Plurals
[3] 
https://github.com/sschuberth/sandbox/raw/apktool/app/build/outputs/apk/app-debu
g.apk
[4] 
https://github.com/sschuberth/sandbox/blob/apktool/app/src/main/res/values/plura
ls.xml
[5] 
https://github.com/sschuberth/sandbox/blob/apktool/app-debug/res/values/plurals.
xml

Original issue reported on code.google.com by sschuberth on 22 Jul 2014 at 3:14

GoogleCodeExporter commented 9 years ago
OG String: "%d guide"
Decoded: &lt;b>%d&lt;/b> guide
Rebuilt then Decoded: &amp;lt;b>%d&amp;lt;/b> guide

Yep another problem, even though I think the guidelines say not to do this. 
#391 was suppose to fix this. Will add this as another unit-test and fix.

Original comment by connor.tumbleson on 24 Jul 2014 at 6:45

GoogleCodeExporter commented 9 years ago
Shouldn't the unit test added as part of issue #608 already cover this?

WRT the guidelines, the "Styling with HTML markup" section at [1] basically has 
the same example, saying

    Store your styled text resource as an HTML-escaped string:
    <string name="welcome_messages">Hello, %1$s! You have <b>%2$d new messages</b>.</string>

So using basic HTML text formatting like , <i> and <u> is fine at least in a 
regular string resource, so I guess it's fine for plurals, too.

The only other difference to my example is that I've also escaped the closing 
">" to ">", but while not required this should be fine also. I think it's also 
fine that apktool decodes my original ">" to ">" here as escaping it is 
optional in the first place.

[1] http://developer.android.com/guide/topics/resources/string-resource.html

Original comment by sschuberth on 24 Jul 2014 at 7:40

GoogleCodeExporter commented 9 years ago

Original comment by connor.tumbleson on 2 Oct 2014 at 7:18

GoogleCodeExporter commented 9 years ago
https://github.com/iBotPeaches/Apktool/commit/f9f59bff2234d8ae3a88f00e182e4949bb
96d2f9

Fixed.

Original comment by connor.tumbleson on 3 Mar 2015 at 9:44