Skip to content

Commit

Permalink
Merge pull request #499 from CloudCannon/fix/html-entity-attributes
Browse files Browse the repository at this point in the history
Fix HTML entities in captured metadata and filter attributes
  • Loading branch information
bglw authored Nov 15, 2023
2 parents 5e1ac51 + 9a7ee27 commit a649e8a
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
24 changes: 24 additions & 0 deletions pagefind/features/characters.feature
Original file line number Diff line number Diff line change
Expand Up @@ -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:
"""
<h1 data-pagefind-meta="title">The &quot;bees&quot;</h1>
"""
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:
"""
Expand Down
2 changes: 1 addition & 1 deletion pagefind/src/fossick/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)))
}
}
}
Expand Down

0 comments on commit a649e8a

Please sign in to comment.