From 9a7ee27d6d97fafa8b6d5561ac5c90133c6b574a Mon Sep 17 00:00:00 2001
From: Liam Bigelow <40188355+bglw@users.noreply.github.com>
Date: Wed, 15 Nov 2023 22:24:16 +1300
Subject: [PATCH] Fix HTML entities in capture metadata and tiler attributes
---
pagefind/features/characters.feature | 24 ++++++++++++++++++++++++
pagefind/src/fossick/parser.rs | 2 +-
2 files changed, 25 insertions(+), 1 deletion(-)
diff --git a/pagefind/features/characters.feature b/pagefind/features/characters.feature
index 55797f13..6be5c3cb 100644
--- a/pagefind/features/characters.feature
+++ b/pagefind/features/characters.feature
@@ -83,6 +83,30 @@ Feature: Character Tests
Then There should be no logs
Then The selector "[data-result]" should contain 'The "bees"'
+ Scenario: Pagefind handles HTML entities in meta
+ Given I have a "public/apiary/index.html" file with the body:
+ """
+
The "bees"
+ """
+ When I run my program
+ Then I should see "Running Pagefind" in stdout
+ Then I should see the file "public/pagefind/pagefind.js"
+ When I serve the "public" directory
+ When I load "/"
+ When I evaluate:
+ """
+ async function() {
+ let pagefind = await import("/pagefind/pagefind.js");
+
+ let search = await pagefind.search("bees");
+
+ let pages = await Promise.all(search.results.map(r => r.data()));
+ document.querySelector('[data-result]').innerText = pages.map(p => p.meta.title).join(", ");
+ }
+ """
+ Then There should be no logs
+ Then The selector "[data-result]" should contain 'The "bees"'
+
Scenario: Pagefind can search for a hyphenated phrase
Given I have a "public/ds/index.html" file with the body:
"""
diff --git a/pagefind/src/fossick/parser.rs b/pagefind/src/fossick/parser.rs
index 77ff96f2..6e98bf3b 100644
--- a/pagefind/src/fossick/parser.rs
+++ b/pagefind/src/fossick/parser.rs
@@ -651,7 +651,7 @@ impl DomParsingNode {
if self.current_value.is_empty() {
None
} else {
- Some((input.to_owned(), self.current_value.to_owned()))
+ Some((input.to_owned(), normalize_content(&self.current_value)))
}
}
}