mirror of
https://github.com/ImranR98/Obtainium.git
synced 2025-07-12 21:06:43 +02:00
HTML bugfix: Incorrect URL resolution on redirected pages (#2315)
This commit is contained in:
@ -9,6 +9,13 @@ import 'package:obtainium/providers/apps_provider.dart';
|
|||||||
import 'package:obtainium/providers/source_provider.dart';
|
import 'package:obtainium/providers/source_provider.dart';
|
||||||
|
|
||||||
String ensureAbsoluteUrl(String ambiguousUrl, Uri referenceAbsoluteUrl) {
|
String ensureAbsoluteUrl(String ambiguousUrl, Uri referenceAbsoluteUrl) {
|
||||||
|
try {
|
||||||
|
if (Uri.parse(ambiguousUrl).isAbsolute) {
|
||||||
|
return ambiguousUrl; // #2315
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
//
|
||||||
|
}
|
||||||
return referenceAbsoluteUrl.resolve(ambiguousUrl).toString();
|
return referenceAbsoluteUrl.resolve(ambiguousUrl).toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -360,8 +360,8 @@ Future<File> downloadFile(String url, String fileName, bool fileNameHasExt,
|
|||||||
}
|
}
|
||||||
var responseWithClient =
|
var responseWithClient =
|
||||||
await sourceRequestStreamResponse('GET', url, reqHeaders, {});
|
await sourceRequestStreamResponse('GET', url, reqHeaders, {});
|
||||||
HttpClient responseClient = responseWithClient.key;
|
HttpClient responseClient = responseWithClient.value.key;
|
||||||
HttpClientResponse response = responseWithClient.value;
|
HttpClientResponse response = responseWithClient.value.value;
|
||||||
sink ??= tempDownloadedFile.openWrite(mode: FileMode.writeOnly);
|
sink ??= tempDownloadedFile.openWrite(mode: FileMode.writeOnly);
|
||||||
|
|
||||||
// Perform the download
|
// Perform the download
|
||||||
|
@ -511,7 +511,7 @@ HttpClient createHttpClient(bool insecure) {
|
|||||||
return client;
|
return client;
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<MapEntry<HttpClient, HttpClientResponse>> sourceRequestStreamResponse(
|
Future<MapEntry<Uri, MapEntry<HttpClient, HttpClientResponse>>> sourceRequestStreamResponse(
|
||||||
String method,
|
String method,
|
||||||
String url,
|
String url,
|
||||||
Map<String, String>? requestHeaders,
|
Map<String, String>? requestHeaders,
|
||||||
@ -551,7 +551,7 @@ Future<MapEntry<HttpClient, HttpClientResponse>> sourceRequestStreamResponse(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return MapEntry(httpClient, response);
|
return MapEntry(currentUrl, MapEntry(httpClient, response));
|
||||||
}
|
}
|
||||||
throw ObtainiumError('Too many redirects ($maxRedirects)');
|
throw ObtainiumError('Too many redirects ($maxRedirects)');
|
||||||
}
|
}
|
||||||
@ -637,14 +637,14 @@ abstract class AppSource {
|
|||||||
{bool followRedirects = true, Object? postBody}) async {
|
{bool followRedirects = true, Object? postBody}) async {
|
||||||
var method = postBody == null ? 'GET' : 'POST';
|
var method = postBody == null ? 'GET' : 'POST';
|
||||||
var requestHeaders = await getRequestHeaders(additionalSettings);
|
var requestHeaders = await getRequestHeaders(additionalSettings);
|
||||||
var streamedResponseAndClient = await sourceRequestStreamResponse(
|
var streamedResponseUrlWithResponseAndClient = await sourceRequestStreamResponse(
|
||||||
method, url, requestHeaders, additionalSettings,
|
method, url, requestHeaders, additionalSettings,
|
||||||
followRedirects: followRedirects, postBody: postBody);
|
followRedirects: followRedirects, postBody: postBody);
|
||||||
return await httpClientResponseStreamToFinalResponse(
|
return await httpClientResponseStreamToFinalResponse(
|
||||||
streamedResponseAndClient.key,
|
streamedResponseUrlWithResponseAndClient.value.key,
|
||||||
method,
|
method,
|
||||||
url,
|
streamedResponseUrlWithResponseAndClient.key.toString(),
|
||||||
streamedResponseAndClient.value);
|
streamedResponseUrlWithResponseAndClient.value.value);
|
||||||
}
|
}
|
||||||
|
|
||||||
void runOnAddAppInputChange(String inputUrl) {
|
void runOnAddAppInputChange(String inputUrl) {
|
||||||
|
Reference in New Issue
Block a user