From 4680401808d94fd75dce1db0ccd904c9252c6f2b Mon Sep 17 00:00:00 2001 From: Imran Remtulla Date: Fri, 25 Jul 2025 09:37:43 -0400 Subject: [PATCH] Stop accidentally sharing GitHub/GitLab PATs with Codeberg, Mullvad (#2423) --- lib/app_sources/codeberg.dart | 2 +- lib/app_sources/fdroid.dart | 8 ++++++-- lib/app_sources/github.dart | 3 ++- lib/app_sources/gitlab.dart | 5 +++-- lib/app_sources/mullvad.dart | 2 +- 5 files changed, 13 insertions(+), 7 deletions(-) diff --git a/lib/app_sources/codeberg.dart b/lib/app_sources/codeberg.dart index d54cfe5..6e395f1 100644 --- a/lib/app_sources/codeberg.dart +++ b/lib/app_sources/codeberg.dart @@ -3,7 +3,7 @@ import 'package:obtainium/custom_errors.dart'; import 'package:obtainium/providers/source_provider.dart'; class Codeberg extends AppSource { - GitHub gh = GitHub(); + GitHub gh = GitHub(hostChanged: true); Codeberg() { name = 'Forgejo (Codeberg)'; hosts = ['codeberg.org']; diff --git a/lib/app_sources/fdroid.dart b/lib/app_sources/fdroid.dart index 6d20a02..17df3e4 100644 --- a/lib/app_sources/fdroid.dart +++ b/lib/app_sources/fdroid.dart @@ -112,13 +112,17 @@ class FDroid extends AppSource { bool isGitHub = false; bool isGitLab = false; try { - GitHub().sourceSpecificStandardizeURL(details.changeLog!); + GitHub( + hostChanged: true, + ).sourceSpecificStandardizeURL(details.changeLog!); isGitHub = true; } catch (e) { // } try { - GitLab().sourceSpecificStandardizeURL(details.changeLog!); + GitLab( + hostChanged: true, + ).sourceSpecificStandardizeURL(details.changeLog!); isGitLab = true; } catch (e) { // diff --git a/lib/app_sources/github.dart b/lib/app_sources/github.dart index 560605a..fa15b1a 100644 --- a/lib/app_sources/github.dart +++ b/lib/app_sources/github.dart @@ -13,10 +13,11 @@ import 'package:obtainium/providers/source_provider.dart'; import 'package:url_launcher/url_launcher_string.dart'; class GitHub extends AppSource { - GitHub() { + GitHub({hostChanged = false}) { hosts = ['github.com']; appIdInferIsOptional = true; showReleaseDateAsVersionToggle = true; + this.hostChanged = hostChanged; sourceConfigSettingFormItems = [ GeneratedFormTextField( diff --git a/lib/app_sources/gitlab.dart b/lib/app_sources/gitlab.dart index fab4421..14cc009 100644 --- a/lib/app_sources/gitlab.dart +++ b/lib/app_sources/gitlab.dart @@ -12,10 +12,11 @@ import 'package:easy_localization/easy_localization.dart'; import 'package:url_launcher/url_launcher_string.dart'; class GitLab extends AppSource { - GitLab() { + GitLab({bool hostChanged = false}) { hosts = ['gitlab.com']; canSearch = true; showReleaseDateAsVersionToggle = true; + this.hostChanged = hostChanged; sourceConfigSettingFormItems = [ GeneratedFormTextField( @@ -144,7 +145,7 @@ class GitLab extends AppSource { Map additionalSettings, ) async { // Prepare request params - var names = GitHub().getAppNames(standardUrl); + var names = GitHub(hostChanged: true).getAppNames(standardUrl); String projectUriComponent = '${Uri.encodeComponent(names.author)}%2F${Uri.encodeComponent(names.name)}'; String? PAT = await getPATIfAny(hostChanged ? additionalSettings : {}); diff --git a/lib/app_sources/mullvad.dart b/lib/app_sources/mullvad.dart index 9838392..83be92e 100644 --- a/lib/app_sources/mullvad.dart +++ b/lib/app_sources/mullvad.dart @@ -55,7 +55,7 @@ class Mullvad extends AppSource { } String? changeLog; try { - changeLog = (await GitHub().getLatestAPKDetails( + changeLog = (await GitHub(hostChanged: true).getLatestAPKDetails( 'https://github.com/mullvad/mullvadvpn-app', {'fallbackToOlderReleases': true}, )).changeLog;