Skip to content

Commit

Permalink
Fix Humble Trove url signing (tkashkin#32)
Browse files Browse the repository at this point in the history
Former-commit-id: 4798294
  • Loading branch information
tkashkin committed Dec 21, 2018
1 parent 8289ab5 commit 8146099
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/data/sources/humble/HumbleGame.vala
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,8 @@ namespace GameHub.Data.Sources.Humble
var new_url = installer.update_url(this);
if(new_url != null)
{
info = info.replace(old_url, new_url);
var url_field = "\"web\": \"%s\"";
info = info.replace(url_field.printf(old_url), url_field.printf(new_url));
}
refresh = true;
}
Expand Down Expand Up @@ -371,7 +372,7 @@ namespace GameHub.Data.Sources.Humble
{
id = machine_name;
this.platform = platform;
this.dl_id = download_identifier;
dl_id = download_identifier;
dl_name = download.has_member("name") ? download.get_string_member("name") : "";
var url_obj = download.has_member("url") ? download.get_object_member("url") : null;
var url = url_obj != null && url_obj.has_member("web") ? url_obj.get_string_member("web") : "";
Expand Down
12 changes: 12 additions & 0 deletions src/data/sources/humble/Trove.vala
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,18 @@ namespace GameHub.Data.Sources.Humble
trove_root.foreach_member((trove_root_obj, key, node) => {
if(key == TROVE_INTRO_ID) return;

var obj = node.get_object();
var downloads = obj.get_object_member("downloads");

downloads.foreach_member((downloads_obj, dl_os, dl_node) => {
var dl_obj = dl_node.get_object();
var dl_name = dl_obj.get_string_member("machine_name");
var dl_id = dl_obj.get_object_member("url").get_string_member("web");
dl_obj.set_string_member("download_identifier", dl_id);
var signed_url = sign_url(dl_name, dl_id, user_token);
dl_obj.get_object_member("url").set_string_member("web", signed_url ?? "humble-trove-unsigned://" + dl_name + "/_gh_dl_/" + dl_id);
});

var game = new HumbleGame(this, Trove.FAKE_ORDER, node);

if(game.platforms.size == 0) return;
Expand Down

0 comments on commit 8146099

Please sign in to comment.