mirror of
https://github.com/revanced/Apktool.git
synced 2024-12-13 14:27:46 +01:00
fix of binary xml string length encoding, now supporting long resource strings
This commit is contained in:
parent
3c24735f61
commit
0fa6418553
@ -303,21 +303,21 @@ public class StringBlock {
|
|||||||
private static final int[] getUtf8(byte[] array, int offset) {
|
private static final int[] getUtf8(byte[] array, int offset) {
|
||||||
int val = array[offset];
|
int val = array[offset];
|
||||||
int length;
|
int length;
|
||||||
|
// We skip the utf16 length of the string
|
||||||
if ((val & 0x80) != 0) {
|
if ((val & 0x80) != 0) {
|
||||||
offset += 2;
|
offset += 2;
|
||||||
} else {
|
} else {
|
||||||
offset += 1;
|
offset += 1;
|
||||||
}
|
}
|
||||||
|
// And we read only the utf-8 encoded length of the string
|
||||||
val = array[offset];
|
val = array[offset];
|
||||||
if ((val & 0x80) != 0) {
|
|
||||||
offset += 2;
|
|
||||||
} else {
|
|
||||||
offset += 1;
|
offset += 1;
|
||||||
}
|
if ((val & 0x80) != 0) {
|
||||||
length = 0;
|
int low = (array[offset] & 0xFF);
|
||||||
while (array[offset + length] != 0) {
|
length = ((val & 0x7F) << 8) + low;
|
||||||
length++;
|
offset += 1;
|
||||||
|
} else {
|
||||||
|
length = val;
|
||||||
}
|
}
|
||||||
return new int[] { offset, length};
|
return new int[] { offset, length};
|
||||||
}
|
}
|
||||||
@ -325,10 +325,12 @@ public class StringBlock {
|
|||||||
private static final int[] getUtf16(byte[] array, int offset) {
|
private static final int[] getUtf16(byte[] array, int offset) {
|
||||||
int val = ((array[offset + 1] & 0xFF) << 8 | array[offset] & 0xFF);
|
int val = ((array[offset + 1] & 0xFF) << 8 | array[offset] & 0xFF);
|
||||||
|
|
||||||
if (val == 0x8000) {
|
if ((val & 0x8000) != 0) {
|
||||||
int high = (array[offset + 3] & 0xFF) << 8;
|
int high = (array[offset + 3] & 0xFF) << 8;
|
||||||
int low = (array[offset + 2] & 0xFF);
|
int low = (array[offset + 2] & 0xFF);
|
||||||
return new int[] {4, (high + low) * 2};
|
int len_value = ((val & 0x7FFF) << 16) + (high + low);
|
||||||
|
return new int[] {4, len_value * 2};
|
||||||
|
|
||||||
}
|
}
|
||||||
return new int[] {2, val * 2};
|
return new int[] {2, val * 2};
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user