diff options
author | Sean Whitton <spwhitton@spwhitton.name> | 2021-04-08 23:01:27 -0700 |
---|---|---|
committer | Sean Whitton <spwhitton@spwhitton.name> | 2021-04-08 23:02:29 -0700 |
commit | 33c348551c723f86631028919c5b04cfb70a3284 (patch) | |
tree | 0b8f07614a7131135ee77d076de5462e90a0230b | |
parent | ab1da975f6499985e773e5f71139087ff3b6633f (diff) | |
download | mailscripts-33c348551c723f86631028919c5b04cfb70a3284.tar.gz |
gmi2email: cope with XML feeds sent with text/gemini MIME type
Signed-off-by: Sean Whitton <spwhitton@spwhitton.name>
-rwxr-xr-x | gmi2email | 9 |
1 files changed, 7 insertions, 2 deletions
@@ -121,7 +121,10 @@ foreach my $sub (<$subs_fh>) { }; #>>> next if $next; - if ($type =~ m{^(?:text|application)/(?:(?:atom|rss)\+)?xml}) { + # some XML feeds out there are published using the text/gemini MIME type, + # so also look at the file extension + if ($type =~ m{^(?:text|application)/(?:(?:atom|rss)\+)?xml} + or $sub =~ /\.xml$/) { my $feed = XML::Feed->parse(\$data); for ($feed->entries) { my $date = $_->issued // $_->modified; @@ -219,7 +222,9 @@ sub gemini_fetch { die "while fetching $uri: gemini error: $status $meta"; } - if ($meta =~ "^text/gemini") { + # don't rely only on MIME type server sends us when URI ends in .xml, as + # some feeds out there are published with the text/gemini MIME type + if ($meta =~ "^text/gemini" and not $uri =~ /\.xml\z/) { my @lines; if ($opts{abs_links}) { my $dir = $path =~ s{[^/]*$}{}r =~ s{^/}{}r; |