Fix RSS ampersand issue in blogit.
authorJoann Mõndresku <joann@cernodile.com>
Thu, 15 Jul 2021 21:29:40 +0000 (00:29 +0300)
committerJoann Mõndresku <joann@cernodile.com>
Thu, 15 Jul 2021 21:29:40 +0000 (00:29 +0300)
blogit

diff --git a/blogit b/blogit
index 6035d1ec35526d786dce695752967f397e7121a2..5be242954ea9b3e0d0bab525081ae84cb4591b9f 100755 (executable)
--- a/blogit
+++ b/blogit
@@ -176,11 +176,11 @@ blog/rss.xml: $(ARTICLES)
                git log --diff-filter=A --date="format:%s %a, %d %b %Y %H:%M:%S %z" --pretty=format:'%ad%n' -- "$$f"; \
        done | sort -k2nr | head -n $(BLOG_FEED_MAX) | cut -d" " -f1,3- | while IFS=" " read -r FILE DATE; do \
                printf '<item>\n<title>%s</title>\n<link>%s</link>\n<guid>%s</guid>\n<pubDate>%s</pubDate>\n<description>%s</description>\n</item>\n' \
-                       "`head -n 1 $$FILE`" \
+                       "`head -n 1 $$FILE | sed 's/&/&amp;/'`" \
                        "$(BLOG_URL_ROOT)/`basename $$FILE .md`.html" \
                        "$(BLOG_URL_ROOT)/`basename $$FILE .md`.html" \
                        "$$DATE" \
-                       "`sed -n '1d;/^$$/{2{d;b};q};p' < $$FILE`"; \
+                       "`sed -n 's/&/&amp;/;1d;/^$$/{2{d;b};q};p' < $$FILE`"; \
        done >> $@
        printf '</channel>\n</rss>\n' >> $@
 
@@ -192,12 +192,12 @@ blog/atom.xml: $(ARTICLES)
                git log --diff-filter=A --date="format:%s %Y-%m-%dT%H:%M:%SZ" --pretty=format:'%ad %aN%n' -- "$$f"; \
        done | sort -k2nr | head -n $(BLOG_FEED_MAX) | cut -d" " -f1,3- | while IFS=" " read -r FILE DATE AUTHOR; do \
                printf '<entry>\n<title type="text">%s</title>\n<link rel="alternate" type="text/html" href="%s"/>\n<id>%s</id>\n<published>%s</published>\n<updated>%s</updated>\n<author><name>%s</name></author>\n<summary type="text">%s</summary>\n</entry>\n' \
-                       "`head -n 1 $$FILE`" \
+                       "`head -n 1 $$FILE | sed 's/&/&amp;/'`" \
                        "$(BLOG_URL_ROOT)/`basename $$FILE .md`.html" \
                        "$(BLOG_URL_ROOT)/`basename $$FILE .md`.html" \
                        "$$DATE" \
                        "`git log -n 1 --date="format:%Y-%m-%dT%H:%M:%SZ" --pretty=format:'%ad' -- "$$FILE"`" \
                        "$$AUTHOR" \
-                       "`sed -n '1d;/^$$/{2{d;b};q};p' < $$FILE`"; \
+                       "`sed -n 's/&/&amp;/;1d;/^$$/{2{d;b};q};p' < $$FILE`"; \
        done >> $@
        printf '</feed>\n' >> $@