Handle another round of "ApkEditor" Protect decoding. #3862
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
ApkEditor made some improvements which broke Apktool, but kept working on AOSP. Things I saw:
AndroidManifest.xml
it parses ahead (reading header, jumping to end of chunk) until it finds a few elements and in this caseSTART_ELEMENT
. So when ApkEditor packs bogus chunks ofXML_END_NAMESPACE
andPACKAGE
Apktool may crash out as it tries to parse those as-is in the middle of an XML node and die.REAndroid/APKEditor@4e7ce00
So Apktool made a few changes:
jumpTo
method instead of havingskip
lines around. Even though it does the same thing under the hood - its a bit easier to read/understand. This is helpful because ApkEditor injects a StringPool then marks it as a Package type. So our older code would have attempted to parse the Package type (even if it was going to skip it). So now it just skips a chunk that it does not care about without parsing more than the arsc header.This isn't perfect yet as END_NAMESPACE bogus element could just become any other and Apktool would break again. However, the 15 year old XML node reading code isn't as elegant at the moment to transition into a while() loop of parsing chunks with a preference to skip unknown chunks.
fixes: #3838