mirror of
https://github.com/ImranR98/Obtainium.git
synced 2025-07-16 22:56: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:easy_localization/easy_localization.dart';
|
||||||
import 'package:html/parser.dart';
|
import 'package:html/parser.dart';
|
||||||
import 'package:http/http.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/components/generated_form.dart';
|
||||||
import 'package:obtainium/custom_errors.dart';
|
import 'package:obtainium/custom_errors.dart';
|
||||||
import 'package:obtainium/providers/source_provider.dart';
|
import 'package:obtainium/providers/source_provider.dart';
|
||||||
@ -95,17 +97,32 @@ class FDroid extends AppSource {
|
|||||||
details.names.author =
|
details.names.author =
|
||||||
authorLines.first.split(': ').sublist(1).join(': ');
|
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) {
|
if (changelogUrls.isNotEmpty) {
|
||||||
details.changeLog = changelogUrls.first;
|
details.changeLog = changelogUrls.first;
|
||||||
details.changeLog = (await sourceRequest(
|
bool isGitHub = false;
|
||||||
details.changeLog!
|
bool isGitLab = false;
|
||||||
.split(': ')
|
try {
|
||||||
.sublist(1)
|
GitHub().sourceSpecificStandardizeURL(details.changeLog!);
|
||||||
.join(': ')
|
isGitHub = true;
|
||||||
.replaceFirst('/blob/', '/raw/'),
|
} catch (e) {
|
||||||
additionalSettings))
|
//
|
||||||
.body;
|
}
|
||||||
|
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) {
|
} catch (e) {
|
||||||
// Fail silently
|
// Fail silently
|
||||||
|
@ -358,6 +358,16 @@ class AppsPageState extends State<AppsPage> {
|
|||||||
String? changesUrl =
|
String? changesUrl =
|
||||||
appSource.changeLogPageFromStandardUrl(listedApps[appIndex].app.url);
|
appSource.changeLogPageFromStandardUrl(listedApps[appIndex].app.url);
|
||||||
String? changeLog = listedApps[appIndex].app.changeLog;
|
String? changeLog = listedApps[appIndex].app.changeLog;
|
||||||
|
if (changeLog?.split('\n').length == 1) {
|
||||||
|
if (RegExp(
|
||||||
|
'(http|ftp|https)://([\\w_-]+(?:(?:\\.[\\w_-]+)+))([\\w.,@?^=%&:/~+#-]*[\\w@?^=%&/~+#-])?')
|
||||||
|
.hasMatch(changeLog!)) {
|
||||||
|
if (changesUrl == null) {
|
||||||
|
changesUrl = changeLog;
|
||||||
|
changeLog = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
return (changeLog == null && changesUrl == null)
|
return (changeLog == null && changesUrl == null)
|
||||||
? null
|
? null
|
||||||
: () {
|
: () {
|
||||||
|
Reference in New Issue
Block a user