Skip to content

Commit 9179ec9

Browse files
committed
Merge #578: HTML: xml escape page titles
b843fd7 HTML: xml escape page titles (David A. Harding) Pull request description: When we use HTML directly (not through parsed Markdown), XML entities need to be escaped. Our tests catch cases where that doesn't happen, so we don't need to be fastidious about it, but in this case I was trying to add a page with an ampersand in the title and these were the places where the tests complained. Verified via a diff of the rendered site compared to master that this produces no changes in the rendered site for all current content. Tree-SHA512: edfe471d4d2fcc885612cb85c9eb4cc87b979ca2e8d2bfe52d80cc2b759b20da6600a7bfe612f92145bb935465bfcb54b86ec20db986fca3e18e1d90ff57df2c
2 parents a0ef153 + b843fd7 commit 9179ec9

File tree

5 files changed

+17
-17
lines changed

5 files changed

+17
-17
lines changed

_includes/head.html

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
{% else %}
99
{% assign title = page.title %}
1010
{% endif %}
11-
<title>{{ site.title }}{{ custom }}{% if title %} :: {{ title }}{% endif %}</title>
12-
{% if page.excerpt %}<meta name="description" content="{{ title | strip_html }}">{% endif %}
11+
<title>{{ site.title | xml_escape }}{{ custom | xml_escape }}{% if title %} :: {{ title | xml_escape }}{% endif %}</title>
12+
{% if page.excerpt %}<meta name="description" content="{{ title | strip_html | xml_escape }}">{% endif %}
1313
<meta name="keywords" content="{{ page.tags | join: ', ' }}">
1414
{% if page.author %}
1515
{% assign author = site.data.authors[page.author] %}{% else %}{% assign author = site.owner %}
@@ -24,9 +24,9 @@
2424
{% assign posts=site.posts |where:"name", page.name %}
2525
{% for hrefpost in posts %}<link rel="alternate" hreflang="{{ hrefpost.lang }}" href="{{ site.url }}{{ hrefpost.permalink }}" />{% endfor %}
2626
{% if page.canonical != null %}<link rel="canonical" href="{{ page.canonical }}">{% else %}<link rel="canonical" href="{{ site.url }}{{ page.url }}">{% endif %}
27-
<link href="{{ site.url }}/{{ page.lang }}/feed.xml" type="application/atom+xml" rel="alternate" title="{{ site.title }} Blog XML Feed">
28-
<link href="{{ site.url }}/{{ page.lang }}/rss.xml" type="application/rss+xml" rel="alternate" title="{{ site.title }} Blog RSS Feed">
29-
<link href="{{ site.url }}/{{ page.lang }}/meetingrss.xml" type="application/rss+xml" rel="alternate" title="{{ site.title }} Meeting RSS Feed">
27+
<link href="{{ site.url }}/{{ page.lang }}/feed.xml" type="application/atom+xml" rel="alternate" title="{{ site.title | xml_escape }} Blog XML Feed">
28+
<link href="{{ site.url }}/{{ page.lang }}/rss.xml" type="application/rss+xml" rel="alternate" title="{{ site.title | xml_escape }} Blog RSS Feed">
29+
<link href="{{ site.url }}/{{ page.lang }}/meetingrss.xml" type="application/rss+xml" rel="alternate" title="{{ site.title | xml_escape }} Meeting RSS Feed">
3030

3131
<!-- http://t.co/dKP3o1e -->
3232
<meta name="HandheldFriendly" content="True">

_includes/open-graph.html

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<!-- Twitter Cards -->
2-
<meta name="twitter:title" content="{% if page.title %}{{ page.title }}{% else %}{{ site.title }}{% endif %}">
3-
{% if page.excerpt %}<meta name="twitter:description" content="{{ page.title | strip_html }}">{% endif %}
2+
<meta name="twitter:title" content="{% if page.title %}{{ page.title | xml_escape }}{% else %}{{ site.title | xml_escape }}{% endif %}">
3+
{% if page.excerpt %}<meta name="twitter:description" content="{{ page.title | strip_html | xml_escape }}">{% endif %}
44
{% if site.owner.twitter %}<meta name="twitter:site" content="@{{ site.owner.twitter }}">{% endif %}
55
{% if author.twitter %}<meta name="twitter:creator" content="@{{ author.twitter }}">{% endif %}
66
{% if page.image.feature %}
@@ -13,10 +13,10 @@
1313
<!-- Open Graph -->
1414
<meta property="og:locale" content="{{ page.lang}}">
1515
<meta property="og:type" content="article">
16-
<meta property="og:title" content="{% if page.title %}{{ page.title }}{% else %}{{ site.title }}{% endif %}">
17-
{% if page.excerpt %}<meta property="og:description" content="{{ page.title | strip_html }}">{% endif %}
16+
<meta property="og:title" content="{% if page.title %}{{ page.title | xml_escape }}{% else %}{{ site.title | xml_escape }}{% endif %}">
17+
{% if page.excerpt %}<meta property="og:description" content="{{ page.title | strip_html | xml_escape }}">{% endif %}
1818
<meta property="og:url" content="{{ page.url | replace:'index.html','' | prepend: site.url }}">
19-
<meta property="og:site_name" content="{{ site.title }}">
19+
<meta property="og:site_name" content="{{ site.title | xml_escape }}">
2020
{% if page.image.feature %}
2121
<meta property="og:image" content="{{ site.url }}/assets/images/{{ page.image.feature }}">
2222
{% else %}

_layouts/doc.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
</div>
3131
</div>
3232
<article class="page">
33-
<h1>{{ custom_title }}</h1>
33+
<h1>{{ custom_title | xml_escape }}</h1>
3434
<div class="article-wrap">
3535
{% if page.btcversion != "index" %}
3636
{% assign groups = site.doc | where:"btcversion", page.btcversion | group_by:"btcgroup" | sort: "name" %}

_layouts/page.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
{% else %}
1919
"/assets/images/{{ page.image.feature }}"
2020
{% endif %}
21-
alt="{% if page.image.alt %}{{ page.image.alt }}{% else %}{{ page.title }}{% endif %} feature image">
21+
alt="{% if page.image.alt %}{{ page.image.alt }}{% else %}{{ page.title | xml_escape }}{% endif %} feature image">
2222
{% if page.image.byline %}
2323
<span class="image-credit">{{ page.image.byline }}</span>
2424
{% endif %}
@@ -33,7 +33,7 @@
3333
{% include author-bio.html %}
3434
</div>
3535
<article class="page">
36-
<h1>{{ page.title }}</h1>
36+
<h1>{{ page.title | xml_escape }}</h1>
3737
<div class="article-wrap">
3838
<!-- { % include istranslated.html % } -->
3939
{{ content }}

_layouts/post-index.html

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
{% else %}
1919
"/assets/images/{{ page.image.feature }}"
2020
{% endif %}
21-
alt="{% if page.image.alt %}{{ page.image.alt }}{% else %}{{ page.title }}{% endif %} feature image">
21+
alt="{% if page.image.alt %}{{ page.image.alt }}{% else %}{{ page.title | xml_escape }}{% endif %} feature image">
2222
{% if page.image.byline %}
2323
<span class="image-credit">{{ page.image.byline }}</span>
2424
{% endif %}
@@ -33,7 +33,7 @@
3333
{% include author-bio.html %}
3434
</div>
3535
<div id="index">
36-
<h1>{{ page.title }}</h1>
36+
<h1>{{ page.title | xml_escape }}</h1>
3737
{% capture written_year %}'None'{% endcapture %}
3838
{% assign english_posts=site.posts | where:"lang", 'en' | where:"type", 'posts' %}
3939
{% assign translated_posts=site.posts | where:"lang", page.lang | where:"type", 'posts' %}
@@ -49,9 +49,9 @@ <h3 class="year">{{ year }}</h3>
4949
{% endif %}
5050
<article>
5151
{% if post.link %}
52-
<h2 class="link-post"><a href="{{ post.url }}" title="{{ post.title }}">{{ post.title }}</a> <a href="{{ post.link }}" target="_blank" title="{{ post.title }}"><i class="fa fa-link"></i></a></h2>
52+
<h2 class="link-post"><a href="{{ post.url }}" title="{{ post.title | xml_escape }}">{{ post.title | xml_escape }}</a> <a href="{{ post.link }}" target="_blank" title="{{ post.title | xml_escape }}"><i class="fa fa-link"></i></a></h2>
5353
{% else %}
54-
<h2><a href="{{ post.url }}" title="{{ post.title }}">{{ post.title }}</a></h2>
54+
<h2><a href="{{ post.url }}" title="{{ post.title | xml_escape }}">{{ post.title }}</a></h2>
5555
<p>{{ post.excerpt | markdownify | strip_html | truncate: 160 }}</p>
5656
{% endif %}
5757
</article>

0 commit comments

Comments
 (0)