consistency with entity escaping

This commit is contained in:
rhiannon morris 2024-10-21 14:36:11 +02:00
parent 18629cb220
commit 645424a7d8
3 changed files with 8 additions and 5 deletions

View file

@ -64,7 +64,8 @@ escId = foldMap esc1 . Strict.unpack where
escAttr :: Strict.Text -> Builder
escAttr = foldMap esc1 . Strict.unpack where
esc1 c = fromMaybe (singleton c) $ lookup c
[('<', "&lt;"), ('>', "&gt;"), ('"', "&quot;"), ('\'', "&apos;")]
[('<', "&lt;"), ('>', "&gt;"), ('"', "&quot;"), ('\'', "&apos;"),
('&', "&amp;")]
class CanBuild a where build :: a -> Builder

View file

@ -156,7 +156,7 @@ makeItem nsfw file info@(Info {bg}) = [b|
</figure>
|]
where
title = fromMaybe info.title info.galleryTitle
title = escAttr $ fromMaybe info.title info.galleryTitle
dir = takeDirectory file
thumbnail = getThumb dir info
nsfw' = if nsfw && anyNsfw info then [b|$& nsfw|] else ""

View file

@ -95,7 +95,7 @@ make' root siteName prefix nsfw _dataDir dir
Just (Artist {name}) -> [b|by $name|]
Nothing -> "by niss"
let alt = image0.desc
let alt = escAttr image0.desc
let updateDate = ifJust (last' updates) \(d, _) ->
let updated = formatLong d in
@ -117,6 +117,8 @@ make' root siteName prefix nsfw _dataDir dir
|]
Nothing -> throw $ NoThumb dir
let escTitle = escAttr title
pure [b|
<!DOCTYPE html>
<html lang=en>
@ -140,13 +142,13 @@ make' root siteName prefix nsfw _dataDir dir
$prefetches
<title>$title</title>
<title>$escTitle</title>
$nsfwDialog
<div class=page>
<header>
<h1>$title</h1>
<h1>$escTitle</h1>
<h2 id=date class="right corner">
$formattedDate $updateDate
</h2>