-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
Detect multiple subtitle languages #1723
Conversation
Co-authored-by: Ramires Viana <59319979+ramiresviana@users.noreply.github.com>
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$`) |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
.
Resolves #1702 as suggested in this comment.