aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Lu <chris.lu@gmail.com>2020-09-10 19:46:00 -0700
committerChris Lu <chris.lu@gmail.com>2020-09-10 19:46:02 -0700
commitcc5fe6f5eeb1936f172d0b6e409826c6420454e9 (patch)
treec92d53af8f30750db6a4d3b9f2b3eaeb84e50b90
parent575250438de440f5cf20ed505cc0a6cb796a20a3 (diff)
downloadseaweedfs-cc5fe6f5eeb1936f172d0b6e409826c6420454e9.tar.xz
seaweedfs-cc5fe6f5eeb1936f172d0b6e409826c6420454e9.zip
handle special characters in html link
-rw-r--r--weed/server/filer_ui/templates.go15
1 files changed, 12 insertions, 3 deletions
diff --git a/weed/server/filer_ui/templates.go b/weed/server/filer_ui/templates.go
index e532b27e2..04a81433b 100644
--- a/weed/server/filer_ui/templates.go
+++ b/weed/server/filer_ui/templates.go
@@ -3,10 +3,19 @@ package master_ui
import (
"github.com/dustin/go-humanize"
"html/template"
+ "net/url"
+ "strings"
)
+func printpath(parts ...string) string {
+ concat := strings.Join(parts, "")
+ escaped := url.PathEscape(concat)
+ return strings.ReplaceAll(escaped, "%2F", "/")
+}
+
var funcMap = template.FuncMap{
"humanizeBytes": humanize.Bytes,
+ "printpath": printpath,
}
var StatusTpl = template.Must(template.New("status").Funcs(funcMap).Parse(`<!DOCTYPE html>
@@ -50,7 +59,7 @@ var StatusTpl = template.Must(template.New("status").Funcs(funcMap).Parse(`<!DOC
<div class="row">
<div>
{{ range $entry := .Breadcrumbs }}
- <a href="{{ $entry.Link }}" >
+ <a href="{{ printpath $entry.Link }}" >
{{ $entry.Name }}
</a>
{{ end }}
@@ -69,11 +78,11 @@ var StatusTpl = template.Must(template.New("status").Funcs(funcMap).Parse(`<!DOC
<td>
{{if $entry.IsDirectory}}
<img src="/seaweedfsstatic/images/folder.gif" width="20" height="23">
- <a href={{ print $path "/" $entry.Name "/"}} >
+ <a href="{{ printpath $path "/" $entry.Name "/"}}" >
{{ $entry.Name }}
</a>
{{else}}
- <a href={{ print $path "/" $entry.Name }} >
+ <a href="{{ printpath $path "/" $entry.Name }}" >
{{ $entry.Name }}
</a>
{{end}}