From 1f92ebecba77d11189551060166bd094aa4b3ea8 Mon Sep 17 00:00:00 2001 From: Guilherme Simoes Date: Fri, 10 Apr 2020 22:51:13 +0100 Subject: [PATCH] Fix generation of feed when post title contains HTML (#305) Merge pull request 305 --- lib/jekyll-feed/feed.xml | 6 ++++-- spec/fixtures/_posts/2014-03-04-march-the-fourth.md | 1 + spec/jekyll-feed_spec.rb | 4 ++++ 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/lib/jekyll-feed/feed.xml b/lib/jekyll-feed/feed.xml index 4d4fd16d..a7417ec2 100644 --- a/lib/jekyll-feed/feed.xml +++ b/lib/jekyll-feed/feed.xml @@ -45,8 +45,10 @@ {% endif %} {% for post in posts limit: 10 %} - {{ post.title | smartify | strip_html | normalize_whitespace | xml_escape }} - + {% assign post_title = post.title | smartify | strip_html | normalize_whitespace | xml_escape %} + + {{ post_title }} + {{ post.date | date_to_xmlschema }} {{ post.last_modified_at | default: post.date | date_to_xmlschema }} {{ post.id | absolute_url | xml_escape }} diff --git a/spec/fixtures/_posts/2014-03-04-march-the-fourth.md b/spec/fixtures/_posts/2014-03-04-march-the-fourth.md index 817ee53b..3e3ff140 100644 --- a/spec/fixtures/_posts/2014-03-04-march-the-fourth.md +++ b/spec/fixtures/_posts/2014-03-04-march-the-fourth.md @@ -1,4 +1,5 @@ --- +title: Sparkling Title tags: - '"/>' image: diff --git a/spec/jekyll-feed_spec.rb b/spec/jekyll-feed_spec.rb index 9dce5cea..aa5596fb 100644 --- a/spec/jekyll-feed_spec.rb +++ b/spec/jekyll-feed_spec.rb @@ -87,6 +87,10 @@ expect(contents).to match 'The plugin will properly strip newlines.' end + it "strips HTML from link titles" do + expect(contents).to match %r!! + end + it "renders Liquid inside posts" do expect(contents).to match "Liquid is rendered." expect(contents).not_to match "Liquid is not rendered."