mirror of
https://github.com/ImranR98/Obtainium.git
synced 2025-07-16 14:46:44 +02:00
F-Droid: Don't pull changelog text if it isn't a raw file from GitHub/GitLab (#1340)
This commit is contained in:
@ -3,6 +3,8 @@ import 'dart:convert';
|
||||
import 'package:easy_localization/easy_localization.dart';
|
||||
import 'package:html/parser.dart';
|
||||
import 'package:http/http.dart';
|
||||
import 'package:obtainium/app_sources/github.dart';
|
||||
import 'package:obtainium/app_sources/gitlab.dart';
|
||||
import 'package:obtainium/components/generated_form.dart';
|
||||
import 'package:obtainium/custom_errors.dart';
|
||||
import 'package:obtainium/providers/source_provider.dart';
|
||||
@ -95,17 +97,32 @@ class FDroid extends AppSource {
|
||||
details.names.author =
|
||||
authorLines.first.split(': ').sublist(1).join(': ');
|
||||
}
|
||||
var changelogUrls = lines.where((l) => l.startsWith('Changelog: '));
|
||||
var changelogUrls = lines
|
||||
.where((l) => l.startsWith('Changelog: '))
|
||||
.map((e) => e.split(' ').sublist(1).join(' '));
|
||||
if (changelogUrls.isNotEmpty) {
|
||||
details.changeLog = changelogUrls.first;
|
||||
details.changeLog = (await sourceRequest(
|
||||
details.changeLog!
|
||||
.split(': ')
|
||||
.sublist(1)
|
||||
.join(': ')
|
||||
.replaceFirst('/blob/', '/raw/'),
|
||||
additionalSettings))
|
||||
.body;
|
||||
bool isGitHub = false;
|
||||
bool isGitLab = false;
|
||||
try {
|
||||
GitHub().sourceSpecificStandardizeURL(details.changeLog!);
|
||||
isGitHub = true;
|
||||
} catch (e) {
|
||||
//
|
||||
}
|
||||
try {
|
||||
GitLab().sourceSpecificStandardizeURL(details.changeLog!);
|
||||
isGitLab = true;
|
||||
} catch (e) {
|
||||
//
|
||||
}
|
||||
if ((isGitHub || isGitLab) &&
|
||||
(details.changeLog?.indexOf('/blob/') ?? -1) >= 0) {
|
||||
details.changeLog = (await sourceRequest(
|
||||
details.changeLog!.replaceFirst('/blob/', '/raw/'),
|
||||
additionalSettings))
|
||||
.body;
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
// Fail silently
|
||||
|
Reference in New Issue
Block a user