From 435b9f4541a140d426755d4f25f065781f9fa09b Mon Sep 17 00:00:00 2001 From: Lukas Bestle Date: Tue, 23 Aug 2022 22:18:14 +0200 Subject: [PATCH] Template escaping --- site/snippets/blocks/image.php | 9 +++++---- site/snippets/footer.php | 2 +- site/snippets/header.php | 6 +++--- site/snippets/intro.php | 4 ++-- site/snippets/layouts.php | 4 ++-- site/snippets/note.php | 2 +- site/templates/about.php | 6 +++--- site/templates/default.php | 2 +- site/templates/home.php | 2 +- site/templates/note.php | 8 ++++---- site/templates/notes.php | 2 +- site/templates/photography.php | 2 +- 12 files changed, 25 insertions(+), 24 deletions(-) diff --git a/site/snippets/blocks/image.php b/site/snippets/blocks/image.php index 51994c9..577a3ac 100644 --- a/site/snippets/blocks/image.php +++ b/site/snippets/blocks/image.php @@ -23,10 +23,11 @@ $src = null; $lightbox = $link->isEmpty(); if ($block->location() == 'web') { - $src = $block->src(); + $src = $block->src(); + $srcValue = $src->escape('attr'); } elseif ($image = $block->image()->toFile()) { $alt = $alt->or($image->alt()); - $src = $image->url(); + $src = $srcValue = $image->url(); } if ($ratio !== 'auto') { @@ -44,10 +45,10 @@ $attrs = attr([ ]); ?> - +
> - <?= $alt ?> + <?= esc($alt, 'attr') ?> isNotEmpty()): ?> diff --git a/site/snippets/footer.php b/site/snippets/footer.php index 769e836..0540f2c 100644 --- a/site/snippets/footer.php +++ b/site/snippets/footer.php @@ -23,7 +23,7 @@

Pages

diff --git a/site/snippets/header.php b/site/snippets/header.php index 762da8a..7daf30e 100644 --- a/site/snippets/header.php +++ b/site/snippets/header.php @@ -24,7 +24,7 @@ site and the title of the current page */ ?> - <?= $site->title() ?> | <?= $page->title() ?> + <?= $site->title()->esc() ?> | <?= $page->title()->esc() ?> diff --git a/site/snippets/intro.php b/site/snippets/intro.php index 3409cdd..28680e3 100644 --- a/site/snippets/intro.php +++ b/site/snippets/intro.php @@ -13,8 +13,8 @@ */ ?>
-

headline()->or($page->title())->html() ?>

+

headline()->or($page->title())->esc() ?>

subheadline()->isNotEmpty()): ?> -

subheadline()->html() ?>

+

subheadline()->esc() ?>

diff --git a/site/snippets/layouts.php b/site/snippets/layouts.php index 8c65174..8449779 100644 --- a/site/snippets/layouts.php +++ b/site/snippets/layouts.php @@ -11,9 +11,9 @@ */ ?> toLayouts() as $layout): ?> -
+
columns() as $column): ?> -
+
blocks() ?>
diff --git a/site/snippets/note.php b/site/snippets/note.php index ad801bd..4873f4a 100644 --- a/site/snippets/note.php +++ b/site/snippets/note.php @@ -18,7 +18,7 @@
-

title() ?>

+

title()->esc() ?>

diff --git a/site/templates/about.php b/site/templates/about.php index cd7bc1b..3e6851b 100644 --- a/site/templates/about.php +++ b/site/templates/about.php @@ -33,15 +33,15 @@

Email

-

email()) ?>

+

email()) ?>

Phone

-

phone()) ?>

+

phone()) ?>

On the web

diff --git a/site/templates/default.php b/site/templates/default.php index 0eeef81..ca1afbd 100644 --- a/site/templates/default.php +++ b/site/templates/default.php @@ -21,7 +21,7 @@
-

title()->html() ?>

+

title()->esc() ?>

text()->kt() ?>
diff --git a/site/templates/home.php b/site/templates/home.php index 544e47c..2adf29e 100644 --- a/site/templates/home.php +++ b/site/templates/home.php @@ -48,7 +48,7 @@
- title()->html() ?> + title()->esc() ?>
diff --git a/site/templates/note.php b/site/templates/note.php index eef9020..8d775c3 100644 --- a/site/templates/note.php +++ b/site/templates/note.php @@ -31,9 +31,9 @@
-

title()->html() ?>

+

title()->esc() ?>

subheading()->isNotEmpty()): ?> -

subheading()->html() ?>

+

subheading()->esc() ?>

@@ -44,13 +44,13 @@
  • - +
- + diff --git a/site/templates/notes.php b/site/templates/notes.php index ebb8b22..c233a45 100644 --- a/site/templates/notes.php +++ b/site/templates/notes.php @@ -26,7 +26,7 @@

- Tag: + Tag: ×

diff --git a/site/templates/photography.php b/site/templates/photography.php index fb9364f..09ac34c 100644 --- a/site/templates/photography.php +++ b/site/templates/photography.php @@ -30,7 +30,7 @@ cover()) ? $cover->crop(400, 500) : null ?>
- title()->html() ?> + title()->esc() ?>