secure filename in webvtt regex against accidental evaluation
Co-authored-by: Ramires Viana <59319979+ramiresviana@users.noreply.github.com>
This commit is contained in:
parent
d1b4d54ccf
commit
39abd1da6d
@ -279,7 +279,7 @@ func (i *FileInfo) detectSubtitles() {
|
|||||||
dir, err := afs.ReadDir(parentDir)
|
dir, err := afs.ReadDir(parentDir)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
base := strings.TrimSuffix(i.Name, ext)
|
base := strings.TrimSuffix(i.Name, ext)
|
||||||
r := regexp.MustCompile(base + `\.(.*\.)?vtt`)
|
r := regexp.MustCompile("^" + regexp.QuoteMeta(base) + `\.(.*\.)?vtt$`)
|
||||||
for _, f := range dir {
|
for _, f := range dir {
|
||||||
if !f.IsDir() {
|
if !f.IsDir() {
|
||||||
if matches := r.FindStringSubmatch(f.Name()); len(matches) == 2 {
|
if matches := r.FindStringSubmatch(f.Name()); len(matches) == 2 {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user