Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix feed link when post title contains HTML #305

Merged
merged 1 commit into from
Apr 10, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions lib/jekyll-feed/feed.xml
Original file line number Diff line number Diff line change
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 }}" />
DirtyF marked this conversation as resolved.
Show resolved Hide resolved
<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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
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