Skip to content

Quality: Subtitle deletion matches on substring extension, can delete non-subtitle files#2584

Merged
fire-light42 merged 2 commits intorecloudstream:masterfrom
Nam0101:contribai/improve/quality/subtitle-deletion-matches-on-substring-e
Mar 29, 2026
Merged

Quality: Subtitle deletion matches on substring extension, can delete non-subtitle files#2584
fire-light42 merged 2 commits intorecloudstream:masterfrom
Nam0101:contribai/improve/quality/subtitle-deletion-matches-on-substring-e

Conversation

@Nam0101
Copy link
Copy Markdown
Contributor

@Nam0101 Nam0101 commented Mar 29, 2026

Problem

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.

Severity: high
File: app/src/main/java/com/lagradost/cloudstream3/utils/SubtitleUtils.kt

Solution

Match only by true file extension. Replace the extension check with endsWith on a normalized filename: val lower = name.lowercase() val hasValidExtension = allowedExtensions.any { lower.endsWith(it) } Keep deletion gated on this stricter check.

Changes

  • app/src/main/java/com/lagradost/cloudstream3/utils/SubtitleUtils.kt (modified)

Testing

  • Existing tests pass
  • Manual review completed
  • No new warnings/errors introduced

…e 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 <nam.nv205106@gmail.com>
@fire-light42
Copy link
Copy Markdown
Collaborator

Nice catch! I doubt it has accidentally deleted anything, but it is a very unnecessary risk.

Remember to mark your pull requests as AI assisted as per our AI Policy if you used AI for anything in the pull request.

@fire-light42 fire-light42 merged commit 81c7d90 into recloudstream:master Mar 29, 2026
2 checks passed
@Nam0101 Nam0101 deleted the contribai/improve/quality/subtitle-deletion-matches-on-substring-e branch March 30, 2026 04:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants