Escape URLs properly

This commit is contained in:
Citlali del Rey 2022-11-12 16:33:27 -08:00
parent 2b060366f0
commit 0c61594252
Signed by: nullobsi
GPG Key ID: 933A1F44222C2634
3 changed files with 7 additions and 4 deletions

View File

@ -219,6 +219,8 @@ sub get_entry($fullpath) {
return undef; return undef;
} }
my $url = Mojo::URL->new("https://unix.dog/announcement/");
$url->path(basename($fullpath));
return { return {
raw => $announce_content, raw => $announce_content,
@ -226,6 +228,7 @@ sub get_entry($fullpath) {
date => $filestat->mtime, date => $filestat->mtime,
filename => basename($fullpath), filename => basename($fullpath),
title => $announce_title, title => $announce_title,
url => $url,
}; };
} }

View File

@ -19,7 +19,7 @@
<h2><%= $entry->{"title"} %></h2> <h2><%= $entry->{"title"} %></h2>
<p> <p>
Posted <%= localtime($entry->{"date"})->strftime() %>. Posted <%= localtime($entry->{"date"})->strftime() %>.
<a href="/announcement/<%= $entry->{"filename"} %>">Download PGP signature.</a> <a href="<% $entry->{url} %>">Download PGP signature.</a>
<p> <p>
<pre><%= $entry->{"text"} %></pre> <pre><%= $entry->{"text"} %></pre>
</article> </article>

View File

@ -15,10 +15,10 @@
% foreach my $item (@$items) { % foreach my $item (@$items) {
<item> <item>
<title><![CDATA[<%= $item->{'title'} %>]]></title> <title><![CDATA[<%= $item->{'title'} %>]]></title>
<link>https://unix.dog/announcement/<%= $item->{'filename'} %></link> <link><%= $item->{'url'} %></link>
<guid isPermaLink="true">https://unix.dog/announcement/<%= $item->{'filename'} %></guid> <guid isPermaLink="true"><%= $item->{'url'} %></guid>
<description><![CDATA[<%== $item->{'text'} %>]]></description> <description><![CDATA[<%== $item->{'text'} %>]]></description>
<author>Alpha</author> <author>alpha@unix.dog</author>
<pubDate><%= localtime($item->{'date'})->strftime("%a, %d %b %Y %H:%M:%S %z") %></pubDate> <pubDate><%= localtime($item->{'date'})->strftime("%a, %d %b %Y %H:%M:%S %z") %></pubDate>
</item> </item>
% } % }