mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2024-01-19 02:48:24 +00:00
handle special characters in html link
This commit is contained in:
parent
575250438d
commit
cc5fe6f5ee
|
@ -3,10 +3,19 @@ package master_ui
|
||||||
import (
|
import (
|
||||||
"github.com/dustin/go-humanize"
|
"github.com/dustin/go-humanize"
|
||||||
"html/template"
|
"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{
|
var funcMap = template.FuncMap{
|
||||||
"humanizeBytes": humanize.Bytes,
|
"humanizeBytes": humanize.Bytes,
|
||||||
|
"printpath": printpath,
|
||||||
}
|
}
|
||||||
|
|
||||||
var StatusTpl = template.Must(template.New("status").Funcs(funcMap).Parse(`<!DOCTYPE html>
|
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 class="row">
|
||||||
<div>
|
<div>
|
||||||
{{ range $entry := .Breadcrumbs }}
|
{{ range $entry := .Breadcrumbs }}
|
||||||
<a href="{{ $entry.Link }}" >
|
<a href="{{ printpath $entry.Link }}" >
|
||||||
{{ $entry.Name }}
|
{{ $entry.Name }}
|
||||||
</a>
|
</a>
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
@ -69,11 +78,11 @@ var StatusTpl = template.Must(template.New("status").Funcs(funcMap).Parse(`<!DOC
|
||||||
<td>
|
<td>
|
||||||
{{if $entry.IsDirectory}}
|
{{if $entry.IsDirectory}}
|
||||||
<img src="/seaweedfsstatic/images/folder.gif" width="20" height="23">
|
<img src="/seaweedfsstatic/images/folder.gif" width="20" height="23">
|
||||||
<a href={{ print $path "/" $entry.Name "/"}} >
|
<a href="{{ printpath $path "/" $entry.Name "/"}}" >
|
||||||
{{ $entry.Name }}
|
{{ $entry.Name }}
|
||||||
</a>
|
</a>
|
||||||
{{else}}
|
{{else}}
|
||||||
<a href={{ print $path "/" $entry.Name }} >
|
<a href="{{ printpath $path "/" $entry.Name }}" >
|
||||||
{{ $entry.Name }}
|
{{ $entry.Name }}
|
||||||
</a>
|
</a>
|
||||||
{{end}}
|
{{end}}
|
||||||
|
|
Loading…
Reference in a new issue