Commit 62fea30e authored by Matthew Holt's avatar Matthew Holt

browse: Sanitize file names and links in default template

Thanks to Kevin Froman (@beardog108) for the responsible heads up.
parent bbee9614
...@@ -101,7 +101,7 @@ func browseParse(c *caddy.Controller) ([]Config, error) { ...@@ -101,7 +101,7 @@ func browseParse(c *caddy.Controller) ([]Config, error) {
const defaultTemplate = `<!DOCTYPE html> const defaultTemplate = `<!DOCTYPE html>
<html> <html>
<head> <head>
<title>{{.Name}}</title> <title>{{html .Name}}</title>
<meta charset="utf-8"> <meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<style> <style>
...@@ -323,7 +323,7 @@ footer { ...@@ -323,7 +323,7 @@ footer {
<header> <header>
<h1> <h1>
{{range $url, $name := .BreadcrumbMap}}<a href="{{$url}}">{{$name}}</a>{{if ne $url "/"}}/{{end}}{{end}} {{range $url, $name := .BreadcrumbMap}}<a href="{{html $url}}">{{html $name}}</a>{{if ne $url "/"}}/{{end}}{{end}}
</h1> </h1>
</header> </header>
<main> <main>
...@@ -385,13 +385,13 @@ footer { ...@@ -385,13 +385,13 @@ footer {
{{- range .Items}} {{- range .Items}}
<tr class="file"> <tr class="file">
<td> <td>
<a href="{{.URL}}"> <a href="{{html .URL}}">
{{- if .IsDir}} {{- if .IsDir}}
<svg width="1.5em" height="1em" version="1.1" viewBox="0 0 35.678803 28.527945"><use xlink:href="#folder"></use></svg> <svg width="1.5em" height="1em" version="1.1" viewBox="0 0 35.678803 28.527945"><use xlink:href="#folder"></use></svg>
{{- else}} {{- else}}
<svg width="1.5em" height="1em" version="1.1" viewBox="0 0 26.604381 29.144726"><use xlink:href="#file"></use></svg> <svg width="1.5em" height="1em" version="1.1" viewBox="0 0 26.604381 29.144726"><use xlink:href="#file"></use></svg>
{{- end}} {{- end}}
<span class="name">{{.Name}}</span> <span class="name">{{html .Name}}</span>
</a> </a>
</td> </td>
{{- if .IsDir}} {{- if .IsDir}}
...@@ -407,7 +407,7 @@ footer { ...@@ -407,7 +407,7 @@ footer {
</div> </div>
</main> </main>
<footer> <footer>
Served with <a rel="noopener noreferrer" href="https://caddyserver.com">Caddy</a>. Served with <a rel="noopener noreferrer" href="https://caddyserver.com">Caddy</a>
</footer> </footer>
<script> <script>
var filterEl = document.getElementById('filter'); var filterEl = document.getElementById('filter');
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment