all repos — flounder @ fd9aa385a5daab5f5a8f1f012fd2c57d622012c2

A small site builder for the Gemini protocol

make gemini url safe
alex wennerberg alex@alexwennerberg.com
Tue, 26 Jan 2021 20:54:14 -0800
commit

fd9aa385a5daab5f5a8f1f012fd2c57d622012c2

parent

79daa8d529197d67dfbc7d81cc57a9419a3a55d5

2 files changed, 8 insertions(+), 2 deletions(-)

jump to
M http.gohttp.go

@@ -772,7 +772,13 @@ }

func runHTTPServer() { log.Printf("Running http server with hostname %s on port %d.", c.Host, c.HttpPort) var err error - t = template.New("main").Funcs(template.FuncMap{"parent": path.Dir, "hasSuffix": strings.HasSuffix}) + t = template.New("main").Funcs(template.FuncMap{"parent": path.Dir, "hasSuffix": strings.HasSuffix, + "safeGeminiURL": func(u string) template.URL { + if strings.HasPrefix(u, "gemini://") { + return template.URL(u) + } + return "" + }}) t, err = t.ParseGlob(path.Join(c.TemplatesDirectory, "*.html")) if err != nil { log.Fatal(err)
M templates/user_page.htmltemplates/user_page.html

@@ -22,7 +22,7 @@ <br>

<br> {{ end }} <div class="footer"> - Proxied from the original at <a href="{{.URI.String}}">{{.URI.String}}</a> (<a href="https://admin.flounder.online/gemini.gmi">about Gemini</a>) <a href="?raw=1">raw</a></div> + Proxied from the original at <a href="{{safeGeminiURL .URI.String}}">{{.URI.String}}</a> (<a href="https://admin.flounder.online/gemini.gmi">about Gemini</a>) <a href="?raw=1">raw</a></div> </main> </body> </html>