properly escape quotes in titles and descriptions
This commit is contained in:
parent
eb99fb0a0a
commit
1af5f6c357
|
@ -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 %}
|
||||
|
|
|
@ -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(/<title>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
|
||||
|
|
Loading…
Reference in New Issue