patched by Julio B <julio.bacel@gmail.com> to escape xml in feeds

This commit is contained in:
James Tomasino 2024-02-07 13:06:45 +00:00
parent fca7fa9296
commit ef2d799e81
2 changed files with 7 additions and 4 deletions

View File

@ -22,13 +22,15 @@ if [ "$run_user" -eq 0 ]; then
printf "<id>gopher://cosmic.voyage/</id>\\n"
} > "${gopher_atom}"
xml_escape_script='s/&/\&amp;/g; s/</\&lt;/g; s/>/\&gt;/g; s/"/\&quot;/g; s/'"'"'/\&#39;/g'
# Loop through listings gophermap
loop=0
while read -r line; do
loop=$((loop+1))
if [ "$loop" -lt 20 ]; then
log=$(printf "%s" "$line" | awk -F'\t' '{print $2}')
title=$(printf "%s" "$line" | awk -F'\t' '{print $1}' | sed 's|^.||')
title=$(printf "%s" "$line" | awk -F'\t' '{print $1}' | sed -e 's|^.||' -e "$xml_escape_script")
owner=$(stat -c %U "/var/gopher${log}")
# print item entry for each log
@ -42,7 +44,7 @@ if [ "$run_user" -eq 0 ]; then
printf " <id>gopher://cosmic.voyage/0%s</id>\\n" "$(printf "%s" "$log" | sed 's|\ |%20|g')"
printf " <updated>%s</updated>\\n" "$(date -d "$(stat -c %y "/var/gopher${log}")" +'%Y-%m-%dT%H:%M:%SZ')"
printf " <content type=\"html\"><![CDATA[<pre>\\n"
sed 's/&/\&amp;/g; s/</\&lt;/g; s/>/\&gt;/g; s/"/\&quot;/g; s/'"'"'/\&#39;/g' "/var/gopher${log}"
sed "$xml_escape_script" "/var/gopher${log}"
printf "</pre>]]></content>\\n"
printf "</entry>\\n"

View File

@ -17,6 +17,7 @@ if [ "$run_user" -eq 0 ]; then
printf "<description>Messages from the human stellar diaspora</description>\\n"
} > "${gopher_rss}"
xml_escape_script='s/&/\&amp;/g; s/</\&lt;/g; s/>/\&gt;/g; s/"/\&quot;/g; s/'"'"'/\&#39;/g'
# Loop through listings gophermap
loop=0
@ -24,7 +25,7 @@ if [ "$run_user" -eq 0 ]; then
loop=$((loop+1))
if [ "$loop" -lt 20 ]; then
log=$(printf "%s" "$line" | awk -F'\t' '{print $2}')
title=$(printf "%s" "$line" | awk -F'\t' '{print $1}' | sed 's|^.||')
title=$(printf "%s" "$line" | awk -F'\t' '{print $1}' | sed -e 's|^.||' -e "$xml_escape_script")
owner=$(stat -c %U "/var/gopher${log}")
# print item entry for each log
@ -36,7 +37,7 @@ if [ "$run_user" -eq 0 ]; then
printf " <guid>gopher://cosmic.voyage/0%s</guid>\\n" "$(printf "%s" "$log" | sed 's|\ |%20|g')"
printf " <pubDate>%s GMT</pubDate>\\n" "$(date -d "$(stat -c %y "/var/gopher${log}")" +'%a, %d %b %Y %H:%M:%S')"
printf " <description><![CDATA[<pre>\\n"
sed 's/&/\&amp;/g; s/</\&lt;/g; s/>/\&gt;/g; s/"/\&quot;/g; s/'"'"'/\&#39;/g' "/var/gopher${log}"
sed "$xml_escape_script" "/var/gopher${log}"
printf "</pre>]]></description>\\n"
printf "</item>\\n"
} >> "${gopher_rss}"