check column name pattern
This commit is contained in:
parent
09f6343ced
commit
459d559a34
|
@ -50,6 +50,7 @@ import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.WeakHashMap;
|
import java.util.WeakHashMap;
|
||||||
import java.util.concurrent.atomic.AtomicBoolean;
|
import java.util.concurrent.atomic.AtomicBoolean;
|
||||||
|
import java.util.regex.Pattern;
|
||||||
import java.util.zip.GZIPInputStream;
|
import java.util.zip.GZIPInputStream;
|
||||||
import java.util.zip.ZipException;
|
import java.util.zip.ZipException;
|
||||||
|
|
||||||
|
@ -89,6 +90,8 @@ public class ImportBackupService extends Service {
|
||||||
SQLiteAxolotlStore.SIGNED_PREKEY_TABLENAME,
|
SQLiteAxolotlStore.SIGNED_PREKEY_TABLENAME,
|
||||||
SQLiteAxolotlStore.SESSION_TABLENAME,
|
SQLiteAxolotlStore.SESSION_TABLENAME,
|
||||||
SQLiteAxolotlStore.IDENTITIES_TABLENAME);
|
SQLiteAxolotlStore.IDENTITIES_TABLENAME);
|
||||||
|
private static final Pattern COLUMN_PATTERN = Pattern.compile("^[a-zA-Z_]+$");
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate() {
|
public void onCreate() {
|
||||||
|
@ -364,6 +367,7 @@ public class ImportBackupService extends Service {
|
||||||
jsonReader.beginObject();
|
jsonReader.beginObject();
|
||||||
while (jsonReader.peek() != JsonToken.END_OBJECT) {
|
while (jsonReader.peek() != JsonToken.END_OBJECT) {
|
||||||
final String name = jsonReader.nextName();
|
final String name = jsonReader.nextName();
|
||||||
|
if (COLUMN_PATTERN.matcher(name).matches()) {
|
||||||
if (jsonReader.peek() == JsonToken.NULL) {
|
if (jsonReader.peek() == JsonToken.NULL) {
|
||||||
jsonReader.nextNull();
|
jsonReader.nextNull();
|
||||||
contentValues.putNull(name);
|
contentValues.putNull(name);
|
||||||
|
@ -372,6 +376,9 @@ public class ImportBackupService extends Service {
|
||||||
} else {
|
} else {
|
||||||
contentValues.put(name, jsonReader.nextString());
|
contentValues.put(name, jsonReader.nextString());
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
throw new IOException(String.format("Unexpected column name %s", name));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
jsonReader.endObject();
|
jsonReader.endObject();
|
||||||
jsonReader.endObject();
|
jsonReader.endObject();
|
||||||
|
|
Loading…
Reference in a new issue