Skip to content

Commit

Permalink
Fix generation of feed when post title contains HTML (#305)
Browse files Browse the repository at this point in the history
Merge pull request 305
  • Loading branch information
guilhermesimoes committed Apr 10, 2020
1 parent 4866d6d commit 1f92ebe
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
6 changes: 4 additions & 2 deletions lib/jekyll-feed/feed.xml
Expand Up @@ -45,8 +45,10 @@
{% endif %}
{% for post in posts limit: 10 %}
<entry{% if post.lang %}{{" "}}xml:lang="{{ post.lang }}"{% endif %}>
<title type="html">{{ post.title | smartify | strip_html | normalize_whitespace | xml_escape }}</title>
<link href="{{ post.url | absolute_url }}" rel="alternate" type="text/html" title="{{ post.title | xml_escape }}" />
{% assign post_title = post.title | smartify | strip_html | normalize_whitespace | xml_escape %}

<title type="html">{{ post_title }}</title>
<link href="{{ post.url | absolute_url }}" rel="alternate" type="text/html" title="{{ post_title }}" />
<published>{{ post.date | date_to_xmlschema }}</published>
<updated>{{ post.last_modified_at | default: post.date | date_to_xmlschema }}</updated>
<id>{{ post.id | absolute_url | xml_escape }}</id>
Expand Down
1 change: 1 addition & 0 deletions spec/fixtures/_posts/2014-03-04-march-the-fourth.md
@@ -1,4 +1,5 @@
---
title: <span class="highlight">Sparkling</span> Title
tags:
- '"/><VADER>'
image:
Expand Down
4 changes: 4 additions & 0 deletions spec/jekyll-feed_spec.rb
Expand Up @@ -87,6 +87,10 @@
expect(contents).to match '<title type="html">The plugin will properly strip newlines.</title>'
end

it "strips HTML from link titles" do
expect(contents).to match %r!<link .* title="Sparkling Title" />!
end

it "renders Liquid inside posts" do
expect(contents).to match "Liquid is rendered."
expect(contents).not_to match "Liquid is not rendered."
Expand Down

0 comments on commit 1f92ebe

Please sign in to comment.