diff --git a/lib/template.html b/lib/template.html index 1366740..5d92d0b 100644 --- a/lib/template.html +++ b/lib/template.html @@ -18,7 +18,7 @@ {% endif %} {% endif %} {% if seo_title %} - {% assign seo_title = seo_title | markdownify | strip_html | strip_newlines | escape_once %} + {% assign seo_title = seo_title | replace:'"','"' | markdownify | strip_html | strip_newlines | replace:'"','"' | escape_once %} {% endif %} {% if page.description %} @@ -27,7 +27,7 @@ {% assign seo_description = site.description %} {% endif %} {% if seo_description %} - {% assign seo_description = seo_description | markdownify | strip_html | strip_newlines | escape_once %} + {% assign seo_description = seo_description | replace:'"','"' | markdownify | strip_html | strip_newlines | replace:'"','"' | escape_once %} {% endif %} {% if seo_title %} diff --git a/spec/jekyll_seo_tag_spec.rb b/spec/jekyll_seo_tag_spec.rb index 9f9d6fa..a351859 100644 --- a/spec/jekyll_seo_tag_spec.rb +++ b/spec/jekyll_seo_tag_spec.rb @@ -35,7 +35,14 @@ describe Jekyll::SeoTag do it "escapes titles" do site = site({"title" => 'Jekyll & "Hyde"'}) context = context({ :site => site }) - expect(subject.render(context)).to match(/Jekyll & “Hyde”<\/title>/) + expect(subject.render(context)).to match(/<title>Jekyll & "Hyde"<\/title>/) + end + + it "escapes descriptions" do + site = site({"description" => 'Jekyll & "Hyde"'}) + context = context({ :site => site }) + expected = /<meta name="description" content="Jekyll & "Hyde"" \/>/ + expect(subject.render(context)).to match(expected) end it "uses the page description" do