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

XML escape the title field of feed_meta #306

Merged
merged 4 commits into from Apr 13, 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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/jekyll-feed/meta-tag.rb
Expand Up @@ -7,7 +7,7 @@ class MetaTag < Liquid::Tag

def render(context)
@context = context
attrs = attributes.map { |k, v| %(#{k}="#{v}") }.join(" ")
attrs = attributes.map { |k, v| %(#{k}=#{v.encode(:xml => :attr)}) }.join(" ")
"<link #{attrs} />"
end

Expand Down
9 changes: 9 additions & 0 deletions spec/jekyll-feed_spec.rb
Expand Up @@ -207,6 +207,15 @@
expect(feed.title.content).to eql(site_title)
end
end

context "with site.title has special characters" do
let(:site_title) { "My Site Title <&>" }
let(:overrides) { { "title" => site_title } }

it "uses encoded site.title for the title" do
expect(feed.title.content).to eql(site_title.encode(xml: :text))
end
end
end

context "smartify" do
Expand Down