also use path escaping function for whole-template links
This commit is contained in:
parent
d937ea6562
commit
d78429129f
@ -37,7 +37,13 @@ func NewWikiServer(opts *ServerOptions) (*WikiServer, error) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
tmpl, err := template.New("yatwiki/page").Parse(pageTemplate)
|
tmpl := template.New("yatwiki/page")
|
||||||
|
tmpl.Funcs(map[string]interface{}{
|
||||||
|
"pathcomponent": func(s string) string {
|
||||||
|
return url.PathEscape(s)
|
||||||
|
},
|
||||||
|
})
|
||||||
|
_, err = tmpl.Parse(pageTemplate)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -85,13 +85,13 @@ function els(e,s){ // no js exec in innerHTML
|
|||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div class="header">
|
<div class="header">
|
||||||
<a href="{{.BaseURL}}view/{{.DefaultPage | urlquery}}" title="Home"><div class="sprite hm"></div></a>
|
<a href="{{.BaseURL}}view/{{.DefaultPage | pathcomponent}}" title="Home"><div class="sprite hm"></div></a>
|
||||||
<a href="javascript:;" onclick="tid('spm');tid('tr1');tid('tr2');" title="Menu"><div class="sprite sp"></div></a>
|
<a href="javascript:;" onclick="tid('spm');tid('tr1');tid('tr2');" title="Menu"><div class="sprite sp"></div></a>
|
||||||
<a href="{{.BaseURL}}modify/{{.NewArticleTitle | urlquery}}" title="New Page"><div class="sprite nw"></div></a>
|
<a href="{{.BaseURL}}modify/{{.NewArticleTitle | pathcomponent}}" title="New Page"><div class="sprite nw"></div></a>
|
||||||
{{if .CurrentPageIsArticle }}
|
{{if .CurrentPageIsArticle }}
|
||||||
<div class="sep"></div>
|
<div class="sep"></div>
|
||||||
<a href="{{.BaseURL}}history/{{.CurrentPageName | urlquery}}" title="Page History"><div class="sprite hs"></div></a>
|
<a href="{{.BaseURL}}history/{{.CurrentPageName | pathcomponent}}" title="Page History"><div class="sprite hs"></div></a>
|
||||||
<a href="{{.BaseURL}}modify/{{.CurrentPageName | urlquery}}" title="Modify Page"><div class="sprite ed"></div></a>
|
<a href="{{.BaseURL}}modify/{{.CurrentPageName | pathcomponent}}" title="Modify Page"><div class="sprite ed"></div></a>
|
||||||
{{end}}
|
{{end}}
|
||||||
</div>
|
</div>
|
||||||
<div id="tr1" style="display:none;"></div>
|
<div id="tr1" style="display:none;"></div>
|
||||||
|
Loading…
Reference in New Issue
Block a user