sky201503 / android-apktool2

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

line break in xml if value contains "\n" #181

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. decode an apk (tested it with settings.apk from english miui pack)

What is the expected output? What do you see instead?
<string name="keyname">val\nue</string>
<string name="keyname">val
ue</string>

What version of the product are you using? On what operating system?
1.4.1 and self compiled 1.4.2, Win 7 x64

Please provide any additional information below.
Sometimes a xml file contains a line break(\n), until apktool 1.3.2 it was 
correctly written in the xml file. Since 1.4.0 apktool interprets the line 
breaks. This breaks the whole xml file then.
Here is a sample apk: http://www.multiupload.com/QYXCXTWMFK (settings.apk from 
miui)
Decode it, open values-en\strings.xml and scroll to line 224.

It looks like this:
    <string name="bluetooth_enter_pin_msg">"
Type PIN to pair with \"%1$s\". (Try 0000 or 1234.)"</string>

but it should look like this:

    <string name="bluetooth_enter_pin_msg">"\nType PIN to pair with \"%1$s\". (Try 0000 or 1234.)"</string>

Original issue reported on code.google.com by auer.man...@gmail.com on 19 Jun 2011 at 4:02

GoogleCodeExporter commented 9 years ago
They're 2 variants of exactly the same value. You could check this by yourself.

I've changed this behavior in v1.4.0 because it's much more readable to use 
multiple lines than escaping with \n.

Original comment by Brut.alll on 19 Jun 2011 at 7:24

GoogleCodeExporter commented 9 years ago
Ahh, you should note this isn't:

<string>
</string>

as you described it, but:

<string>"
"</string>

Quotes tell Android to not ignore white spaces.

Original comment by Brut.alll on 19 Jun 2011 at 7:26

GoogleCodeExporter commented 9 years ago
My problem is that I use another program that reads the xml file line by line.
And it doesn't work if the value is in 2 lines. One line has to contain 
everything, the key and the value.
Could you tell me what I would have to change to get everything in one line 
again like it was in 1.3.2?
Thank you!

Original comment by auer.man...@gmail.com on 19 Jun 2011 at 7:29

GoogleCodeExporter commented 9 years ago
This should work for you: http://pastebin.com/MHX4dfsB . You will have to 
modify or disable tests (mvn package -Dmaven.test.skip=true).

But take into account resource XMLs aren't 100% compatible with "normal" XML. 
For example value of <tag>""</tag> is actually an empty string.

Original comment by Brut.alll on 19 Jun 2011 at 7:49

GoogleCodeExporter commented 9 years ago
Thank you!
This works perfectly. Maybe (just maybe ;)) you wanna make an option for it ;)
And maybe you wanna build in the quiet option too :)
Thank you again!

Original comment by auer.man...@gmail.com on 19 Jun 2011 at 8:06

GoogleCodeExporter commented 9 years ago
"Maybe (just maybe ;)) you wanna make an option for it"

I don't think so :-) There are many things which can be decoded in various 
forms and end users of apktool probably don't care about the format I choose. 
On the other hand tool developers can modify apktool sources to their needs.

I'll comment your Issue 182, don't worry ;-)

Original comment by Brut.alll on 19 Jun 2011 at 9:52