From 36c9709bc4cf67e51aac8ff7e1e901800cadf249 Mon Sep 17 00:00:00 2001 From: Ploum Date: Sat, 10 Feb 2024 22:09:28 +0100 Subject: [PATCH] consider files as XML, not SVG, if no .svg extension --- CHANGELOG | 1 + ansicat.py | 3 +++ 2 files changed, 4 insertions(+) diff --git a/CHANGELOG b/CHANGELOG index c745776..f8cafaf 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -15,6 +15,7 @@ - opnk: added "--mode" command-line argument (bug #39) - offpunk: support for "preformatted" theming (bug #38) - opnk/netcache: added "--cache-validity" command-line argument (bug #37) +- ansicat: consider files as XML, not SVG, if they don’t have .svg extension ## 2.1 - December 15th 2023 - freshly updated gemtext/rss links are highlighted ("new_link" theme option) diff --git a/ansicat.py b/ansicat.py index 2dd6308..af33bb5 100755 --- a/ansicat.py +++ b/ansicat.py @@ -1355,6 +1355,9 @@ def get_mime(path,url=None): # If it’s a xml file, consider it as such, regardless of what file thinks elif path.endswith(".xml"): mime = "text/xml" + # If it doesn’t end with .svg, it is probably an xml, not a SVG file + elif "svg" in mime and not path.endswith(".svg"): + mime = "text/xml" #Some xml/html document are considered as octet-stream if mime == "application/octet-stream": mime = "text/xml"