From 33c348551c723f86631028919c5b04cfb70a3284 Mon Sep 17 00:00:00 2001 From: Sean Whitton Date: Thu, 8 Apr 2021 23:01:27 -0700 Subject: gmi2email: cope with XML feeds sent with text/gemini MIME type Signed-off-by: Sean Whitton --- gmi2email | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/gmi2email b/gmi2email index 0a65504..8be383a 100755 --- a/gmi2email +++ b/gmi2email @@ -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; -- cgit v1.2.3