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

View file

@ -156,7 +156,7 @@ makeItem nsfw file info@(Info {bg}) = [b|
</figure> </figure>
|] |]
where where
title = fromMaybe info.title info.galleryTitle title = escAttr $ fromMaybe info.title info.galleryTitle
dir = takeDirectory file dir = takeDirectory file
thumbnail = getThumb dir info thumbnail = getThumb dir info
nsfw' = if nsfw && anyNsfw info then [b|$& nsfw|] else "" 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|] Just (Artist {name}) -> [b|by $name|]
Nothing -> "by niss" Nothing -> "by niss"
let alt = image0.desc let alt = escAttr image0.desc
let updateDate = ifJust (last' updates) \(d, _) -> let updateDate = ifJust (last' updates) \(d, _) ->
let updated = formatLong d in let updated = formatLong d in
@ -117,6 +117,8 @@ make' root siteName prefix nsfw _dataDir dir
|] |]
Nothing -> throw $ NoThumb dir Nothing -> throw $ NoThumb dir
let escTitle = escAttr title
pure [b| pure [b|
<!DOCTYPE html> <!DOCTYPE html>
<html lang=en> <html lang=en>
@ -140,13 +142,13 @@ make' root siteName prefix nsfw _dataDir dir
$prefetches $prefetches
<title>$title</title> <title>$escTitle</title>
$nsfwDialog $nsfwDialog
<div class=page> <div class=page>
<header> <header>
<h1>$title</h1> <h1>$escTitle</h1>
<h2 id=date class="right corner"> <h2 id=date class="right corner">
$formattedDate $updateDate $formattedDate $updateDate
</h2> </h2>