From 58f2dcd72290626a9b558d669b00036cce981caa Mon Sep 17 00:00:00 2001 From: Luna712 <142361265+Luna712@users.noreply.github.com> Date: Fri, 29 May 2026 10:11:07 -0600 Subject: [PATCH] Fixes --- .../network/WebViewResolver.android.kt | 3 ++- .../com/lagradost/cloudstream3/MainAPI.kt | 1 + .../cloudstream3/extractors/ByseSX.kt | 3 ++- .../cloudstream3/extractors/Dailymotion.kt | 3 ++- .../extractors/helper/NineAnimeHelper.kt | 4 +-- .../cloudstream3/utils/ExtractorApi.kt | 3 ++- .../cloudstream3/utils/StringUtils.kt | 26 +++---------------- 7 files changed, 14 insertions(+), 29 deletions(-) diff --git a/library/src/androidMain/kotlin/com/lagradost/cloudstream3/network/WebViewResolver.android.kt b/library/src/androidMain/kotlin/com/lagradost/cloudstream3/network/WebViewResolver.android.kt index a5ffce5f8a2..2f9c9b628cd 100644 --- a/library/src/androidMain/kotlin/com/lagradost/cloudstream3/network/WebViewResolver.android.kt +++ b/library/src/androidMain/kotlin/com/lagradost/cloudstream3/network/WebViewResolver.android.kt @@ -16,6 +16,7 @@ import com.lagradost.cloudstream3.utils.Coroutines.mainWork import com.lagradost.cloudstream3.utils.Coroutines.runOnMainThread import com.lagradost.nicehttp.requestCreator import io.ktor.http.Url +import io.ktor.http.decodeURLPart import kotlinx.coroutines.delay import kotlinx.coroutines.runBlocking import okhttp3.Interceptor @@ -211,7 +212,7 @@ actual class WebViewResolver actual constructor( * */ return@runBlocking try { when { - blacklistedFiles.any { Url(webViewUrl).encodedPath.contains(it) } || webViewUrl.endsWith( + blacklistedFiles.any { Url(webViewUrl).encodedPath.decodeURLPart().contains(it) } || webViewUrl.endsWith( "/favicon.ico" ) -> WebResourceResponse( "image/png", diff --git a/library/src/commonMain/kotlin/com/lagradost/cloudstream3/MainAPI.kt b/library/src/commonMain/kotlin/com/lagradost/cloudstream3/MainAPI.kt index 88c65d2140c..fa673cbe039 100644 --- a/library/src/commonMain/kotlin/com/lagradost/cloudstream3/MainAPI.kt +++ b/library/src/commonMain/kotlin/com/lagradost/cloudstream3/MainAPI.kt @@ -1340,6 +1340,7 @@ fun MainAPI.updateUrl(url: String): String { URLBuilder().apply { takeFrom(updated) user = original.user + password = original.password encodedPath = original.encodedPath fragment = original.fragment diff --git a/library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/ByseSX.kt b/library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/ByseSX.kt index ae9e6c5cf64..b29d29f5d4e 100644 --- a/library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/ByseSX.kt +++ b/library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/ByseSX.kt @@ -9,6 +9,7 @@ import com.lagradost.cloudstream3.utils.ExtractorApi import com.lagradost.cloudstream3.utils.ExtractorLink import com.lagradost.cloudstream3.utils.M3u8Helper import io.ktor.http.Url +import io.ktor.http.decodeURLPart import javax.crypto.Cipher import javax.crypto.spec.GCMParameterSpec import javax.crypto.spec.SecretKeySpec @@ -49,7 +50,7 @@ open class ByseSX : ExtractorApi() { } private fun getCodeFromUrl(url: String): String { - val path = Url(url).encodedPath + val path = Url(url).encodedPath.decodeURLPart() return path.trimEnd('/').substringAfterLast('/') } diff --git a/library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/Dailymotion.kt b/library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/Dailymotion.kt index bb8da63af69..4732cafcf6f 100644 --- a/library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/Dailymotion.kt +++ b/library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/Dailymotion.kt @@ -8,6 +8,7 @@ import com.lagradost.cloudstream3.utils.ExtractorApi import com.lagradost.cloudstream3.utils.ExtractorLink import com.lagradost.cloudstream3.utils.M3u8Helper.Companion.generateM3u8 import io.ktor.http.Url +import io.ktor.http.decodeURLPart class Geodailymotion : Dailymotion() { override val name = "GeoDailymotion" @@ -65,7 +66,7 @@ open class Dailymotion : ExtractorApi() { } private fun getVideoId(url: String): String? { - val path = Url(url).encodedPath + val path = Url(url).encodedPath.decodeURLPart() val id = path.substringAfter("/video/") return if (id.matches(videoIdRegex)) id else null } diff --git a/library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/helper/NineAnimeHelper.kt b/library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/helper/NineAnimeHelper.kt index 473ea5e3b85..c3b50c7a55e 100644 --- a/library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/helper/NineAnimeHelper.kt +++ b/library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/helper/NineAnimeHelper.kt @@ -108,8 +108,6 @@ object NineAnimeHelper { } } - fun encode(input: String): String = - input.encodeUrl().replace("+", "%20") - + fun encode(input: String): String = input.encodeUrl() private fun decode(input: String): String = input.decodeUrl() } \ No newline at end of file diff --git a/library/src/commonMain/kotlin/com/lagradost/cloudstream3/utils/ExtractorApi.kt b/library/src/commonMain/kotlin/com/lagradost/cloudstream3/utils/ExtractorApi.kt index 392aa79da6f..965aae27ad7 100644 --- a/library/src/commonMain/kotlin/com/lagradost/cloudstream3/utils/ExtractorApi.kt +++ b/library/src/commonMain/kotlin/com/lagradost/cloudstream3/utils/ExtractorApi.kt @@ -310,6 +310,7 @@ import com.lagradost.cloudstream3.extractors.Ztreamhub import com.lagradost.cloudstream3.mvvm.logError import com.lagradost.cloudstream3.utils.Coroutines.atomicListOf import io.ktor.http.Url +import io.ktor.http.decodeURLPart import kotlinx.coroutines.coroutineScope import kotlinx.coroutines.delay import kotlinx.coroutines.ensureActive @@ -414,7 +415,7 @@ enum class ExtractorLinkType { private fun inferTypeFromUrl(url: String): ExtractorLinkType { val path = try { - Url(url).encodedPath + Url(url).encodedPath.decodeURLPart() } catch (_: Throwable) { // don't log magnet links as errors null diff --git a/library/src/commonMain/kotlin/com/lagradost/cloudstream3/utils/StringUtils.kt b/library/src/commonMain/kotlin/com/lagradost/cloudstream3/utils/StringUtils.kt index df806bc1e51..6c778185278 100644 --- a/library/src/commonMain/kotlin/com/lagradost/cloudstream3/utils/StringUtils.kt +++ b/library/src/commonMain/kotlin/com/lagradost/cloudstream3/utils/StringUtils.kt @@ -1,33 +1,15 @@ package com.lagradost.cloudstream3.utils -import io.ktor.http.Url -import io.ktor.http.URLBuilder -import io.ktor.http.path +import io.ktor.http.decodeURLQueryComponent +import io.ktor.http.encodeURLParameter object StringUtils { fun String.decodeUrl(): String { - return try { - val parsed = Url(this) - URLBuilder().apply { - protocol = parsed.protocol - host = parsed.host - port = parsed.port - path(*parsed.segments.toTypedArray()) - parameters.appendAll(parsed.parameters) - fragment = parsed.fragment - }.buildString() - } catch (_: Exception) { - this - } + return this.decodeURLQueryComponent() } fun String.encodeUrl(): String { - return try { - URLBuilder(Url(this)).buildString() - } catch (_: Exception) { - // Fallback for malformed URLs - this - } + return this.encodeURLParameter() } // Deprecate after next stable