aboutsummaryrefslogtreecommitdiff
path: root/cmd
diff options
context:
space:
mode:
authorAlex Scerba <alex@scerba.org>2026-09-08 16:23:06 -0500
committerAlex Scerba <alex@scerba.org>2026-09-08 16:23:06 -0500
commit7003dad563fbccf66189b6118b7c5fa1776fdf71 (patch)
tree85906895023046660921ae2b44e3da8e4539b794 /cmd
parent1ca0a2f50e7e2bed057b1334a40402c653b103fa (diff)
Fix character escaping issues on RSS
Diffstat (limited to 'cmd')
-rw-r--r--cmd/http/feed.go5
-rw-r--r--cmd/http/handle.go3
2 files changed, 6 insertions, 2 deletions
diff --git a/cmd/http/feed.go b/cmd/http/feed.go
index 59f5ad1..e14c250 100644
--- a/cmd/http/feed.go
+++ b/cmd/http/feed.go
@@ -1,6 +1,7 @@
package main
import (
+ "net/url"
"time"
)
@@ -29,8 +30,8 @@ func generateFeed(domain string, posts []*Post) []byte {
entry := `
<entry>
<title>` + post.Title + `</title>
- <link href="https://` + domain + `/blog/` + post.File + `"/>
- <id>https://` + domain + `/blog/` + post.File + `</id>
+ <link href="https://` + domain + `/blog/` + url.QueryEscape(post.File) + `"/>
+ <id>https://` + domain + `/blog/` + url.QueryEscape(post.File) + `</id>
<published>` + post.Date + `T00:00:00.000Z</published>
<updated>` + post.Date + `T00:00:00.000Z</updated>
<summary>Blog post</summary>`
diff --git a/cmd/http/handle.go b/cmd/http/handle.go
index 3d49a59..ac03f6d 100644
--- a/cmd/http/handle.go
+++ b/cmd/http/handle.go
@@ -3,6 +3,7 @@ package main
import (
"bytes"
"net/http"
+ "net/url"
"strings"
"time"
)
@@ -72,6 +73,7 @@ func (app *application) blog(w http.ResponseWriter, r *http.Request) {
return
}
} else if len(path) == 3 {
+ path[2], _ = url.PathUnescape(path[2])
if !app.fileExists("html/" + path[1] + "/" + path[2] + ".tmpl.html") {
app.notFound(w)
return
@@ -98,6 +100,7 @@ func (app *application) archive(w http.ResponseWriter, r *http.Request) {
// Redirect to /blog
http.Redirect(w, r, "/blog", http.StatusFound)
} else if len(path) == 3 {
+ path[2], _ = url.PathUnescape(path[2])
if !app.fileExists("html/" + path[1] + "/" + path[2] + ".tmpl.html") {
app.notFound(w)
return