Skip to content

Commit

Permalink
fix(SecretAccountStore): rethink validation (#744)
Browse files Browse the repository at this point in the history
  • Loading branch information
GeopJr authored Jan 11, 2024
1 parent ea8933a commit 27810d4
Showing 1 changed file with 15 additions and 15 deletions.
30 changes: 15 additions & 15 deletions src/Services/Accounts/SecretAccountStore.vala
Original file line number Diff line number Diff line change
Expand Up @@ -61,19 +61,6 @@ public class Tuba.SecretAccountStore : AccountStore {
}

secrets.foreach (item => {
// HACK for DONT_MATCH_NAME
// https://github.com/GeopJr/Tuba/pull/701
// "Mastodon Account" is not meant to be static
// and might be affected by translations, so
// just keep it as a fallback if xdg:schema
// is not available

bool skip_secret = item.label != _("Mastodon Account");
if (item.attributes.contains ("xdg:schema")) {
skip_secret = item.attributes.get ("xdg:schema") != Build.DOMAIN;
}
if (skip_secret) return;

// TODO: remove uuid fallback
bool force_save = false;
var account = secret_to_account (item, out force_save);
Expand Down Expand Up @@ -249,9 +236,22 @@ public class Tuba.SecretAccountStore : AccountStore {
var parser = new Json.Parser ();
parser.load_from_data (contents, -1);

// TODO: remove uuid fallback
var root = parser.get_root ();
bool had_uuid = root.get_object ().has_member ("uuid");
var root_obj = root.get_object ();

// HACK: Partial makeshift secret validation
// see #742 #701 #114
if (
!root_obj.has_member ("backend")
|| !root_obj.has_member ("acct")
|| !root_obj.has_member ("id")
|| !root_obj.has_member ("client-secret")
|| !root_obj.has_member ("client-id")
|| !root_obj.has_member ("access-token")
) return null;

// TODO: remove uuid fallback
bool had_uuid = root_obj.has_member ("uuid");
account = accounts.create_account (root);

// TODO: remove uuid fallback
Expand Down

0 comments on commit 27810d4

Please sign in to comment.