Fix: Url decode the path value

This commit is contained in:
Neeraj Gupta 2023-01-28 18:27:59 +05:30
parent 4103b776c4
commit 41c33003ac
No known key found for this signature in database
GPG key ID: 3C5A1684DC1729E1
2 changed files with 17 additions and 2 deletions

View file

@ -67,7 +67,8 @@ class Code {
static String _getAccount(Uri uri) {
try {
return uri.path.split(':')[1];
final String path = Uri.decodeComponent(uri.path);
return path.split(':')[1];
} catch (e) {
return "";
}
@ -75,7 +76,8 @@ class Code {
static String _getIssuer(Uri uri) {
try {
return uri.path.split(':')[0].substring(1);
final String path = Uri.decodeComponent(uri.path);
return path.split(':')[0].substring(1);
} catch (e) {
return "";
}

View file

@ -0,0 +1,13 @@
import 'package:ente_auth/models/code.dart';
import 'package:flutter_test/flutter_test.dart';
void main() {
test("parseCodeFromRawData", () {
final code1 = Code.fromRawData(
"otpauth://totp/example%20finance%3Aee%40ff.gg?secret=ASKZNWOU6SVYAMVS",
);
expect(code1.issuer, "example finance");
expect(code1.account, "ee@ff.gg");
expect(code1.secret, "ASKZNWOU6SVYAMVS");
});
}