gddo: clean filepaths before fetching
Fixes #391
Change-Id: I190bb17e76f0f2cb84d9b8c3b7a1f69bc6486649
Reviewed-on: https://go-review.googlesource.com/21898
Reviewed-by: Andrew Gerrand <adg@golang.org>
diff --git a/gosrc/present.go b/gosrc/present.go
index 455804b..49726af 100644
--- a/gosrc/present.go
+++ b/gosrc/present.go
@@ -7,6 +7,7 @@
package gosrc
import (
+ "path/filepath"
"regexp"
"time"
)
@@ -31,7 +32,7 @@
var fnames []string
i := 0
for _, m := range assetPat.FindAllSubmatchIndex(b.data, -1) {
- name := string(b.data[m[4]:m[5]])
+ name := filepath.Clean(string(b.data[m[4]:m[5]]))
switch string(b.data[m[2]:m[3]]) {
case "iframe", "image":
data = append(data, b.data[i:m[4]]...)