-
Notifications
You must be signed in to change notification settings - Fork 140
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Whitespace collapsing, Backslash escaping, Quoted escaping not implemented #51
Comments
Very impressive! I will take a look at it and get back to you. |
Thank you again for such professional issue reporting! Let's start with
<attr name="MyAppTheme" parent="@android:style/Theme.NoTitleBar">
<item name="android:windowBackground">@android:color/transparent</item>
<item name="android:windowNoTitle">true</item>
</attr>
You can consume this somewhere as android:theme="@attr/MyAppTheme" We already implemented escaping crucial characters like I agree with you to follow the standard of what majority of developers are used to. I will try to implement all what you suggested and see if it doesn't affect the points i mentioned. Since you already made this test code, could you please include styled (spannable) strings ? I really confused with
|
Hi! I've updated my test application to include spannable strings. Here is the new apk: app-debug.apk.zip And can also find the source code here: https://github.com/Gbr22/APKEditorTest I don't have an issue with APKEditor/ARSCLib offering a superset of the android strings XML format. (By superset I mean having a more "relaxed" parser that doesn't throw an error for unescaped single quotes But when generating XML, I think it should be done in a way that doesn't cause other tools to throw an error. For example when ARSCLib generates a file that contains the string As for the <font color=#FF0000;size=large>Hello World</font> becomes <font color="#FF0000;size=large">Hello World</font>`
<font color=#FF0000; size=large>Hello World</font> becomes <font color="#FF0000;" size="large">Hello World</font>
<font color="#FF0000;"size="large">Hello World</font> becomes <font color="#FF0000;" size="large">Hello World</font> Android Studio errors if you try to have an attribute without double quotes. If the goal is to have the parser be as relaxed as possible I would have it parse similar to how chrome parses it. So a tag is allowed to have an attribute without the double quotes, but in that case a space ends the attribute. |
I agree with your points, this also benefit us to some degree but the current literal-string way has also huge benefit. I am thinking of keeping both methods by introducing global switch |
I guess the switch may be a solution that makes both crowds happy. |
Describe the bug
Whitespace collapsing, Backslash escaping, Quoted escaping not implemented in APKEditor
See this link for how it should behave: https://developer.android.com/guide/topics/resources/string-resource#escaping_quotes
Build examples:
Whitespace collapsed
Unicode: \u00A9
"That's cool!"
That's cool!
Compile Error
Backslash (\\) (\)
Decompile example: (❌ incorrect, ✅ correct)
"Tab ulated"
Tab\u0009ulated
Tab\tulated
"Tab ulated"
Tab ulated
Tab\u0009ulated
\'single\'
\'single\'
"'single'"
"\'single\'"
'single'
"'single'"
"\"double\""
"\"double\""
\"double\"
"double"
\"double\"
(\\) (\)
(\\) ()
(\) ()
(\\) ()
\u00A9
\u00A9
©
©
©
©
To Reproduce
Steps to reproduce the behavior:
java -jar APKEditor-1.2.6.jar d -dex -i app-debug.apk
andjava -jar APKEditor-1.2.6.jar b -i app-debug_decompile_xml -o packed.apk
See the original strings used to build the apk at
strings (original)
See the expected output in image
strings (original) built with android studio
I also attached the output produced by apktool for reference
strings (apktool decompilation output)
. The decompiled strings created by apktool are different thanstrings (original)
but that is not a problem, as both XML files produce the same apk as seen on imagesstrings (original) built with android studio
andstrings (apktool decompilation output) built with android studio
Problem 1: The output produced by unpacking with APKEditor is not compatible with the format that other tools such as android studio expect.
To reproduce unpack the attached apk. The unpacked strings.xml is not compatible with the format that Android Studio accepts. When trying to build my example apk I get an error due to the unescaped single quotes
'
. After escaping the single quotes with a backslash\
and building the app I get the output seen in the attached imagestrings (APKEditor decompilation output manually edited to escape single quotes) built with android studio
.Problem 2: The APKEditor packer doesn't recognise backslash
\
escape codes and double quoted escapes as its input.To reproduce unpack the attached apk. Edit the strings.xml to the attached
strings (original)
then pack/build with APKEditor. The built apk will produce the output shown in the imagestrings (original) packed with APKEditor
with is not correct.Used apk file
app-debug.apk.zip
Attached XML
strings (original)
strings (APKEditor decompilation output)
strings (APKEditor decompilation output manually edited to escape single quotes)
strings (apktool decompilation output)
Attached images
strings (original) built with android studio
strings (original) built with APKEditor
strings (apktool decompilation output) built with android studio
strings (APKEditor decompilation output manually edited to escape single quotes) built with android studio
The text was updated successfully, but these errors were encountered: