mirror of
https://github.com/revanced/ARSCLib.git
synced 2025-04-30 06:14:25 +02:00
fix: decode null / empty values
This commit is contained in:
parent
d5c3f7563e
commit
fea0583f61
@ -1,4 +1,4 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2022 github.com/REAndroid
|
* Copyright (C) 2022 github.com/REAndroid
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
@ -29,7 +29,7 @@ import java.util.Iterator;
|
|||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
public class ValueDecoder {
|
public class ValueDecoder {
|
||||||
|
|
||||||
public static String escapeSpecialCharacter(String text){
|
public static String escapeSpecialCharacter(String text){
|
||||||
if(text==null || text.length()==0){
|
if(text==null || text.length()==0){
|
||||||
@ -64,7 +64,7 @@ import java.util.regex.Pattern;
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
if("@empty".equals(txt)){
|
if("@empty".equals(txt)){
|
||||||
return new EncodeResult(ValueType.NULL, 0);
|
return new EncodeResult(ValueType.NULL, 1);
|
||||||
}
|
}
|
||||||
if("@null".equals(txt)){
|
if("@null".equals(txt)){
|
||||||
return new EncodeResult(ValueType.REFERENCE, 0);
|
return new EncodeResult(ValueType.REFERENCE, 0);
|
||||||
@ -354,8 +354,8 @@ import java.util.regex.Pattern;
|
|||||||
return decodeIntEntry(store, parentEntry, valueType, data);
|
return decodeIntEntry(store, parentEntry, valueType, data);
|
||||||
}
|
}
|
||||||
public static String decodeIntEntry(EntryStore store, Entry parentEntry, ValueType valueType, int data){
|
public static String decodeIntEntry(EntryStore store, Entry parentEntry, ValueType valueType, int data){
|
||||||
if(valueType==ValueType.NULL){
|
if(valueType == ValueType.NULL){
|
||||||
return "@empty";
|
return decodeNull(data);
|
||||||
}
|
}
|
||||||
if(valueType==ValueType.STRING){
|
if(valueType==ValueType.STRING){
|
||||||
return decodeIntEntryString(parentEntry, data);
|
return decodeIntEntryString(parentEntry, data);
|
||||||
@ -474,6 +474,8 @@ import java.util.regex.Pattern;
|
|||||||
return decodeHex(data);
|
return decodeHex(data);
|
||||||
case INT_DEC:
|
case INT_DEC:
|
||||||
return decodeInt(data);
|
return decodeInt(data);
|
||||||
|
case NULL:
|
||||||
|
return decodeNull(data);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@ -713,6 +715,12 @@ import java.util.regex.Pattern;
|
|||||||
private static String decodeInt(int rawVal){
|
private static String decodeInt(int rawVal){
|
||||||
return String.valueOf(rawVal);
|
return String.valueOf(rawVal);
|
||||||
}
|
}
|
||||||
|
private static String decodeNull(int data){
|
||||||
|
if(data == 1){
|
||||||
|
return "@empty";
|
||||||
|
}
|
||||||
|
return "@null";
|
||||||
|
}
|
||||||
|
|
||||||
private static String decodeBoolean(int data){
|
private static String decodeBoolean(int data){
|
||||||
if(data == 0xFFFFFFFF){
|
if(data == 0xFFFFFFFF){
|
||||||
@ -824,4 +832,4 @@ import java.util.regex.Pattern;
|
|||||||
private static final Pattern PATTERN_HEX = Pattern.compile("^0x[0-9a-fA-F]+$");
|
private static final Pattern PATTERN_HEX = Pattern.compile("^0x[0-9a-fA-F]+$");
|
||||||
public static final Pattern PATTERN_REFERENCE = Pattern.compile("^([?@])(([^\\s:@?/]+:)?)([^\\s:@?/]+)/([^\\s:@?/]+)$");
|
public static final Pattern PATTERN_REFERENCE = Pattern.compile("^([?@])(([^\\s:@?/]+:)?)([^\\s:@?/]+)/([^\\s:@?/]+)$");
|
||||||
public static final Pattern PATTERN_HEX_REFERENCE = Pattern.compile("^([?@])(0x[0-9a-f]{7,8})$");
|
public static final Pattern PATTERN_HEX_REFERENCE = Pattern.compile("^([?@])(0x[0-9a-f]{7,8})$");
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user