diff --git a/templates/EbookGrid.php b/templates/EbookGrid.php
index 1c19b7b4..4fb22e8e 100644
--- a/templates/EbookGrid.php
+++ b/templates/EbookGrid.php
@@ -5,7 +5,6 @@ if($view == ''){
}
$collection = $collection ?? null;
-
$ebooks = $ebooks ?? [];
?>
typeof="schema:BookSeries" about="= $collection->Url ?>" } ?>>
diff --git a/templates/Header.php b/templates/Header.php
index 4f107142..31a7346a 100644
--- a/templates/Header.php
+++ b/templates/Header.php
@@ -5,15 +5,23 @@ $highlight = $highlight ?? '';
$description = $description ?? '';
$manual = $manual ?? false;
$colorScheme = $_COOKIE['color-scheme'] ?? 'auto';
-$xmlDeclaration = $xmlDeclaration ?? true;
+$isXslt = $isXslt ?? false;
$feedUrl = $feedUrl ?? null;
$feedTitle = $feedTitle ?? '';
$is404 = $is404 ?? false;
-if($xmlDeclaration){
- header('content-type: application/xhtml+xml; charset=utf-8');
- print('');
- print("\n");
+// As of Sep 2022, all versions of Safari have a bug where if the page is served as XHTML,
+// then elements download all s instead of the first supported match.
+// So, we try to detect Safari here, and don't use multiple if we find Safari.
+// See https://bugs.webkit.org/show_bug.cgi?id=245411
+$isSafari = stripos($_SERVER['HTTP_USER_AGENT'] ?? '', 'safari') !== false;
+
+if(!$isXslt){
+ if(!$isSafari){
+ header('content-type: application/xhtml+xml; charset=utf-8');
+ print('');
+ print("\n");
+ }
print("\n");
}
?>
diff --git a/www/feeds/atom/style.php b/www/feeds/atom/style.php
index e71469de..9656347f 100644
--- a/www/feeds/atom/style.php
+++ b/www/feeds/atom/style.php
@@ -8,7 +8,7 @@ print("\n")
/* doctype-system outputs the HTML5 doctype */ ?>
- = Template::Header(['xmlDeclaration' => false]) ?>
+ = Template::Header(['isXslt' => true]) ?>
diff --git a/www/feeds/opds/style.php b/www/feeds/opds/style.php
index edbb516b..ff18768f 100644
--- a/www/feeds/opds/style.php
+++ b/www/feeds/opds/style.php
@@ -8,7 +8,7 @@ print("\n")
/* doctype-system outputs the HTML5 doctype */ ?>
- = Template::Header(['xmlDeclaration' => false]) ?>
+ = Template::Header(['isXslt' => true]) ?>
diff --git a/www/feeds/rss/style.php b/www/feeds/rss/style.php
index 236baf4b..b5d5cc2d 100644
--- a/www/feeds/rss/style.php
+++ b/www/feeds/rss/style.php
@@ -8,7 +8,7 @@ print("\n")
/* doctype-system outputs the HTML5 doctype */ ?>
- = Template::Header(['xmlDeclaration' => false]) ?>
+ = Template::Header(['isXslt' => true]) ?>