Skip to content

Commit 9519a3c

Browse files
committed
Fix BreadcrumbList on 404 page and escape JSON-LD output
Skip BreadcrumbList structured data on 404 pages since error pages should not publish structured data. Escape '<' as \u003c in JSON-LD to prevent potential XSS if page titles ever contain </script>.
1 parent 2e8968f commit 9519a3c

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

docs/src/components/starlight/Head.astro

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ if (title !== "RocketSim Docs" && title !== "404") {
4646
});
4747
}
4848
49-
if (breadcrumbItems.length > 1) {
49+
if (breadcrumbItems.length > 1 && title !== "404") {
5050
schemas.push({
5151
"@context": "https://schema.org",
5252
"@type": "BreadcrumbList",
@@ -152,7 +152,7 @@ if (isFaqPage && faqEntries.length > 0) {
152152
<script
153153
type="application/ld+json"
154154
is:inline
155-
set:html={JSON.stringify(schema)}
155+
set:html={JSON.stringify(schema).replaceAll("<", "\\u003c")}
156156
/>
157157
))
158158
}

0 commit comments

Comments
 (0)