From 2b71ae6be120fd88e693d44e7db02bb16910cb77 Mon Sep 17 00:00:00 2001 From: Nguyen Van Nam Date: Mon, 30 Mar 2026 00:40:49 +0700 Subject: [PATCH 1/2] refactor: subtitle deletion matches on substring extension, can delete non-subtitle files `isMatchingSubtitle` checks extensions with `name.contains(...)` instead of checking the actual file suffix. This can classify non-subtitle files as subtitles (e.g. `movie.srt.mp4` contains `.srt`) and delete them in `deleteMatchingSubtitles`, causing real data loss. Affected files: SubtitleUtils.kt Signed-off-by: Nguyen Van Nam --- .../java/com/lagradost/cloudstream3/utils/SubtitleUtils.kt | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/com/lagradost/cloudstream3/utils/SubtitleUtils.kt b/app/src/main/java/com/lagradost/cloudstream3/utils/SubtitleUtils.kt index 18d465e3c5a..edb3cb961cc 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/utils/SubtitleUtils.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/utils/SubtitleUtils.kt @@ -42,8 +42,9 @@ object SubtitleUtils { display: String, cleanDisplay: String ): Boolean { - // Check if the file has a valid subtitle extension - val hasValidExtension = allowedExtensions.any { name.contains(it, ignoreCase = true) } + // Check if the file has a valid subtitle extension + val lowerName = name.lowercase() + val hasValidExtension = allowedExtensions.any { lowerName.endsWith(it) } // We can't have the exact same file as a subtitle val isNotDisplayName = !name.equals(display, ignoreCase = true) From 59f6a7d7611b831e989f55fa492f6bf556c85a62 Mon Sep 17 00:00:00 2001 From: firelight <147925818+fire-light42@users.noreply.github.com> Date: Sun, 29 Mar 2026 18:14:42 +0000 Subject: [PATCH 2/2] Update SubtitleUtils.kt --- .../java/com/lagradost/cloudstream3/utils/SubtitleUtils.kt | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/com/lagradost/cloudstream3/utils/SubtitleUtils.kt b/app/src/main/java/com/lagradost/cloudstream3/utils/SubtitleUtils.kt index edb3cb961cc..c0068f91a83 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/utils/SubtitleUtils.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/utils/SubtitleUtils.kt @@ -42,9 +42,8 @@ object SubtitleUtils { display: String, cleanDisplay: String ): Boolean { - // Check if the file has a valid subtitle extension - val lowerName = name.lowercase() - val hasValidExtension = allowedExtensions.any { lowerName.endsWith(it) } + // Check if the file has a valid subtitle extension + val hasValidExtension = allowedExtensions.any { name.endsWith(it, ignoreCase = true) } // We can't have the exact same file as a subtitle val isNotDisplayName = !name.equals(display, ignoreCase = true) @@ -58,4 +57,4 @@ object SubtitleUtils { fun cleanDisplayName(name: String): String { return name.substringBeforeLast('.').trim() } -} \ No newline at end of file +}