summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSean Whitton <spwhitton@spwhitton.name>2021-04-08 23:01:27 -0700
committerSean Whitton <spwhitton@spwhitton.name>2021-04-08 23:02:29 -0700
commit33c348551c723f86631028919c5b04cfb70a3284 (patch)
tree0b8f07614a7131135ee77d076de5462e90a0230b
parentab1da975f6499985e773e5f71139087ff3b6633f (diff)
downloadmailscripts-33c348551c723f86631028919c5b04cfb70a3284.tar.gz
gmi2email: cope with XML feeds sent with text/gemini MIME type
Signed-off-by: Sean Whitton <spwhitton@spwhitton.name>
-rwxr-xr-xgmi2email9
1 files 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;