mirror of
https://github.com/beemdevelopment/Aegis.git
synced 2025-05-04 12:24:49 +00:00
Fix crash when processing QR code content with a bad URI format
This commit is contained in:
parent
a651378315
commit
926b5139da
2 changed files with 9 additions and 2 deletions
|
@ -48,6 +48,14 @@ public class GoogleAuthInfo {
|
||||||
return builder.build();
|
return builder.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static GoogleAuthInfo parseUri(String s) throws GoogleAuthInfoException {
|
||||||
|
Uri uri = Uri.parse(s);
|
||||||
|
if (uri == null) {
|
||||||
|
throw new GoogleAuthInfoException("bad uri format");
|
||||||
|
}
|
||||||
|
return GoogleAuthInfo.parseUri(uri);
|
||||||
|
}
|
||||||
|
|
||||||
public static GoogleAuthInfo parseUri(Uri uri) throws GoogleAuthInfoException {
|
public static GoogleAuthInfo parseUri(Uri uri) throws GoogleAuthInfoException {
|
||||||
if (!uri.getScheme().equals("otpauth")) {
|
if (!uri.getScheme().equals("otpauth")) {
|
||||||
throw new GoogleAuthInfoException("unsupported protocol");
|
throw new GoogleAuthInfoException("unsupported protocol");
|
||||||
|
|
|
@ -108,8 +108,7 @@ public class ScannerActivity extends AegisActivity implements ZXingScannerView.R
|
||||||
public void handleResult(Result rawResult) {
|
public void handleResult(Result rawResult) {
|
||||||
try {
|
try {
|
||||||
// parse google auth uri
|
// parse google auth uri
|
||||||
Uri uri = Uri.parse(rawResult.getText());
|
GoogleAuthInfo info = GoogleAuthInfo.parseUri(rawResult.getText());
|
||||||
GoogleAuthInfo info = GoogleAuthInfo.parseUri(uri);
|
|
||||||
DatabaseEntry entry = new DatabaseEntry(info);
|
DatabaseEntry entry = new DatabaseEntry(info);
|
||||||
|
|
||||||
Intent intent = new Intent();
|
Intent intent = new Intent();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue