Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Detect multiple subtitle languages #1723

Merged
merged 5 commits into from
Dec 20, 2021

Conversation

mazenbesher
Copy link
Contributor

Resolves #1702 as suggested in this comment.

files/file.go Outdated Show resolved Hide resolved
Co-authored-by: Ramires Viana <59319979+ramiresviana@users.noreply.github.com>
files/file.go Outdated Show resolved Hide resolved
files/file.go Outdated
dir, err := afs.ReadDir(parentDir)
if err == nil {
base := strings.TrimSuffix(i.Name, ext)
r := regexp.MustCompile("^" + regexp.QuoteMeta(base) + `\.(.*\.)?vtt$`)
Copy link
Member

@o1egl o1egl Dec 20, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MustCompile must not be used for user-provided data. Use Compile instead. I think we can use a simple substring check which would be ~200 times faster than regexp https://go.dev/play/p/HOZBYFaGH1Z

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree. This would eliminate the restriction to Base.Lang.vtt.

@o1egl o1egl merged commit c2e03bb into filebrowser:master Dec 20, 2021
@mazenbesher mazenbesher deleted the feature-multiple-subtitles branch December 21, 2021 07:04
rahul-r pushed a commit to rahul-r/filebrowser that referenced this pull request Sep 2, 2022
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.

Detect multiple subtitle languages
3 participants