Skip to content

Commit 505305e

Browse files
committedOct 10, 2021
correctly escape titles subtitles and excerpts in all contexts; fixes #856
1 parent 24e182b commit 505305e

10 files changed

+23
-22
lines changed
 

‎CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
## Unreleased version
22

33
- Added `post_search` config setting that creates a Search button in the navbar (older websites need to set `post_search: true` to enable this feature) (#770)
4+
- Fixed page titles, subtitles, and excerpts rendering correctly when there are special characeters in them (#856)
45
- Slightly reworked margins and position for avatar image to resolve an alignment issue on Safari.
56
- Changed the width at which the navbar collapses to a higher threshold because most modern non-mobile browsers are >1000px
67
- Fixed bug where navbar secondary level dropdown items didn't inherit the same colour as the primary navbar links

‎_includes/header.html

+6-6
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,13 @@
2727
<div class="row">
2828
<div class="col-xl-8 offset-xl-2 col-lg-10 offset-lg-1">
2929
<div class="{{ include.type }}-heading">
30-
<h1>{% if page.title %}{{ page.title }}{% else %}<br/>{% endif %}</h1>
30+
<h1>{% if page.title %}{{ page.title | strip_html }}{% else %}<br/>{% endif %}</h1>
3131
{% if page.subtitle %}
3232
{% if include.type == "page" %}
3333
<hr class="small">
34-
<span class="{{ include.type }}-subheading">{{ page.subtitle }}</span>
34+
<span class="{{ include.type }}-subheading">{{ page.subtitle | strip_html }}</span>
3535
{% else %}
36-
<h2 class="{{ include.type }}-subheading">{{ page.subtitle }}</h2>
36+
<h2 class="{{ include.type }}-subheading">{{ page.subtitle | strip_html }}</h2>
3737
{% endif %}
3838
{% endif %}
3939

@@ -61,13 +61,13 @@ <h2 class="{{ include.type }}-subheading">{{ page.subtitle }}</h2>
6161
<div class="row">
6262
<div class="col-xl-8 offset-xl-2 col-lg-10 offset-lg-1">
6363
<div class="{{ include.type }}-heading">
64-
<h1>{% if page.title %}{{ page.title }}{% else %}<br/>{% endif %}</h1>
64+
<h1>{% if page.title %}{{ page.title | strip_html }}{% else %}<br/>{% endif %}</h1>
6565
{% if page.subtitle %}
6666
{% if include.type == "page" %}
6767
<hr class="small">
68-
<span class="{{ include.type }}-subheading">{{ page.subtitle }}</span>
68+
<span class="{{ include.type }}-subheading">{{ page.subtitle | strip_html }}</span>
6969
{% else %}
70-
<h2 class="{{ include.type }}-subheading">{{ page.subtitle }}</h2>
70+
<h2 class="{{ include.type }}-subheading">{{ page.subtitle | strip_html }}</h2>
7171
{% endif %}
7272
{% endif %}
7373

‎_includes/search.html

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,15 @@
1111
var searchjson = '[ \
1212
{% for post in site.posts %} \
1313
{ \
14-
"title" : "{% if post.title != "" %}{{ post.title | escape }}{% else %}{{ post.excerpt | strip_html | escape | strip }}{%endif%}", \
14+
"title" : "{% if post.title != "" %}{{ post.title | strip_html | escape }}{% else %}{{ post.excerpt | strip_html | escape | strip }}{%endif%}", \
1515
"category" : "{{ post.tags | join: \', \' }}", \
1616
"url" : "{{ site.baseurl }}{{ post.url }}", \
1717
"date" : "{{ post.date | date: "%B %e, %Y" | default: "January 1, 1970" }}" \
1818
}, \
1919
{% endfor %} \
2020
{% for page in site.html_pages %}{% if page.title != "{title}" and page.title != "404 - Page not found" %} \
2121
{ \
22-
"title" : "{% if page.title != "" %}{{ page.title | escape }}{% else %}{{ page.excerpt | strip_html | escape | strip }}{% endif %}", \
22+
"title" : "{% if page.title != "" %}{{ page.title | strip_html | escape }}{% else %}{{ page.excerpt | strip_html | escape | strip }}{% endif %}", \
2323
"category" : "{% if page.tags %}{{ page.tags | join: \', \' }}{% else %}page{% endif %}", \
2424
"url" : "{{ site.baseurl }}{{ page.url }}", \
2525
"date" : "{{ page.date | date: '%B %e, %Y' | default: "January 1, 1970" }}" \

‎_includes/social-share.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
<span class="sr-only">Share: </span>
1212

1313
{% if site.share-links-active.twitter %}
14-
<a href="https://twitter.com/intent/tweet?text={{ page.title | url_encode }}&url={{ page.url | absolute_url | url_encode }}"
14+
<a href="https://twitter.com/intent/tweet?text={{ page.title | strip_html | url_encode }}&url={{ page.url | absolute_url | url_encode }}"
1515
class="btn btn-social-icon btn-twitter" title="Share on Twitter">
1616
<span class="fab fa-fw fa-twitter" aria-hidden="true"></span>
1717
<span class="sr-only">Twitter</span>

‎_layouts/home.html

+3-3
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,11 @@
3535
{% endif %}
3636

3737
<a href="{{ post.url | absolute_url }}">
38-
<h2 class="post-title">{{ post.title }}</h2>
38+
<h2 class="post-title">{{ post.title | strip_html }}</h2>
3939

4040
{% if post.subtitle %}
4141
<h3 class="post-subtitle">
42-
{{ post.subtitle }}
42+
{{ post.subtitle | strip_html }}
4343
</h3>
4444
{% endif %}
4545
</a>
@@ -68,7 +68,7 @@ <h3 class="post-subtitle">
6868

6969
<div class="post-entry">
7070
{% assign excerpt_length = site.excerpt_length | default: 50 %}
71-
{{ post.excerpt | strip_html | xml_escape | truncatewords: excerpt_length }}
71+
{{ post.excerpt | strip_html | truncatewords: excerpt_length }}
7272
{% assign excerpt_word_count = post.excerpt | number_of_words %}
7373
{% if post.content != post.excerpt or excerpt_word_count > excerpt_length %}
7474
<a href="{{ post.url | absolute_url }}" class="post-read-more">[Read&nbsp;More]</a>

‎_layouts/post.html

+2-2
Original file line numberDiff line numberDiff line change
@@ -67,12 +67,12 @@
6767
<ul class="pagination blog-pager">
6868
{% if page.previous.url %}
6969
<li class="page-item previous">
70-
<a class="page-link" href="{{ page.previous.url | relative_url }}" data-toggle="tooltip" data-placement="top" title="{{page.previous.title}}">&larr; Previous Post</a>
70+
<a class="page-link" href="{{ page.previous.url | relative_url }}" data-toggle="tooltip" data-placement="top" title="{{page.previous.title | strip_html | xml_escape}}">&larr; Previous Post</a>
7171
</li>
7272
{% endif %}
7373
{% if page.next.url %}
7474
<li class="page-item next">
75-
<a class="page-link" href="{{ page.next.url | relative_url }}" data-toggle="tooltip" data-placement="top" title="{{page.next.title}}">Next Post &rarr;</a>
75+
<a class="page-link" href="{{ page.next.url | relative_url }}" data-toggle="tooltip" data-placement="top" title="{{page.next.title | strip_html | xml_escape}}">Next Post &rarr;</a>
7676
</li>
7777
{% endif %}
7878
</ul>

‎_posts/2020-02-26-flake-it-till-you-make-it.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
---
22
layout: post
3-
title: Flake it till you make it
4-
subtitle: Excerpt from Soulshaping by Jeff Brown
3+
title: "Flake it & un + he`<i>AA</i>`y <i>BB</i> : per g > % cent ' till y\"ou make it"
4+
subtitle: "Excerpt from \"Soul<i>ITTT</i>shaping by Jeff Brown"
55
cover-img: /assets/img/path.jpg
66
thumbnail-img: /assets/img/thumb.png
77
share-img: /assets/img/path.jpg
88
tags: [books, test]
99
---
1010

11-
Under what circumstances should we step off a path? When is it essential that we finish what we start? If I bought a bag of peanuts and had an allergic reaction, no one would fault me if I threw it out. If I ended a relationship with a woman who hit me, no one would say that I had a commitment problem. But if I walk away from a seemingly secure route because my soul has other ideas, I am a flake?
11+
Under what & f < d > g + g : `<strong>g</strong>`y <strong>sg</strong> e % t ' c " circusmstances should we step off a path? When is it essential that we finish what we start? If I bought a bag of peanuts and had an allergic reaction, no one would fault me if I threw it out. If I ended a relationship with a woman who hit me, no one would say that I had a commitment problem. But if I walk away from a seemingly secure route because my soul has other ideas, I am a flake?
1212

1313
The truth is that no one else can definitively know the path we are here to walk. It’s tempting to listen—many of us long for the omnipotent other—but unless they are genuine psychic intuitives, they can’t know. All others can know is their own truth, and if they’ve actually done the work to excavate it, they will have the good sense to know that they cannot genuinely know anyone else’s. Only soul knows the path it is here to walk. Since you are the only one living in your temple, only you can know its scriptures and interpretive structure.
1414

‎_posts/2020-02-28-test-markdown.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
layout: post
3-
title: Sample blog post
4-
subtitle: Each post also has a subtitle
3+
title: Sample blog <i>fds</i>post
4+
subtitle: Each post al<i>ITAL</i>so has a subtitle
55
gh-repo: daattali/beautiful-jekyll
66
gh-badge: [star, fork, follow]
77
tags: [test]

‎feed.xml

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ layout: null
1515
{% assign excerpt_length = site.excerpt_length | default: 50 %}
1616
{% for post in site.posts limit:20 %}
1717
<item>
18-
<title>{{ post.title | xml_escape }}</title>
18+
<title>{{ post.title | strip_html | xml_escape }}</title>
1919
<description>
20-
{% if post.subtitle %}{{ post.subtitle | xml_escape }} - {% endif %}
20+
{% if post.subtitle %}{{ post.subtitle | strip_html | xml_escape }} - {% endif %}
2121
{{ post.content | strip_html | xml_escape | truncatewords: excerpt_length }}
2222
</description>
2323
<pubDate>{{ post.date | date: "%a, %d %b %Y %H:%M:%S %z" }}</pubDate>

‎tags.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ <h2 id="{{- tag -}}" class="linked-section">
2525
<div class="post-list">
2626
{%- for post in site.tags[tag] -%}
2727
<div class="tag-entry">
28-
<a href="{{ post.url | relative_url }}">{{- post.title -}}</a>
28+
<a href="{{ post.url | relative_url }}">{{- post.title | strip_html -}}</a>
2929
<div class="entry-date">
3030
<time datetime="{{- post.date | date_to_xmlschema -}}">{{- post.date | date: date_format -}}</time>
3131
</div>

0 commit comments

Comments
 (0)
Please sign in to comment.