correctly escape titles subtitles and excerpts in all contexts; fixes #856

This commit is contained in:
Dean Attali 2021-10-10 06:20:54 +00:00
parent 24e182b90e
commit 505305ebe7
10 changed files with 23 additions and 22 deletions

View file

@ -1,6 +1,7 @@
## Unreleased version ## Unreleased version
- 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) - 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)
- Fixed page titles, subtitles, and excerpts rendering correctly when there are special characeters in them (#856)
- Slightly reworked margins and position for avatar image to resolve an alignment issue on Safari. - Slightly reworked margins and position for avatar image to resolve an alignment issue on Safari.
- Changed the width at which the navbar collapses to a higher threshold because most modern non-mobile browsers are >1000px - Changed the width at which the navbar collapses to a higher threshold because most modern non-mobile browsers are >1000px
- Fixed bug where navbar secondary level dropdown items didn't inherit the same colour as the primary navbar links - Fixed bug where navbar secondary level dropdown items didn't inherit the same colour as the primary navbar links

View file

@ -27,13 +27,13 @@
<div class="row"> <div class="row">
<div class="col-xl-8 offset-xl-2 col-lg-10 offset-lg-1"> <div class="col-xl-8 offset-xl-2 col-lg-10 offset-lg-1">
<div class="{{ include.type }}-heading"> <div class="{{ include.type }}-heading">
<h1>{% if page.title %}{{ page.title }}{% else %}<br/>{% endif %}</h1> <h1>{% if page.title %}{{ page.title | strip_html }}{% else %}<br/>{% endif %}</h1>
{% if page.subtitle %} {% if page.subtitle %}
{% if include.type == "page" %} {% if include.type == "page" %}
<hr class="small"> <hr class="small">
<span class="{{ include.type }}-subheading">{{ page.subtitle }}</span> <span class="{{ include.type }}-subheading">{{ page.subtitle | strip_html }}</span>
{% else %} {% else %}
<h2 class="{{ include.type }}-subheading">{{ page.subtitle }}</h2> <h2 class="{{ include.type }}-subheading">{{ page.subtitle | strip_html }}</h2>
{% endif %} {% endif %}
{% endif %} {% endif %}
@ -61,13 +61,13 @@
<div class="row"> <div class="row">
<div class="col-xl-8 offset-xl-2 col-lg-10 offset-lg-1"> <div class="col-xl-8 offset-xl-2 col-lg-10 offset-lg-1">
<div class="{{ include.type }}-heading"> <div class="{{ include.type }}-heading">
<h1>{% if page.title %}{{ page.title }}{% else %}<br/>{% endif %}</h1> <h1>{% if page.title %}{{ page.title | strip_html }}{% else %}<br/>{% endif %}</h1>
{% if page.subtitle %} {% if page.subtitle %}
{% if include.type == "page" %} {% if include.type == "page" %}
<hr class="small"> <hr class="small">
<span class="{{ include.type }}-subheading">{{ page.subtitle }}</span> <span class="{{ include.type }}-subheading">{{ page.subtitle | strip_html }}</span>
{% else %} {% else %}
<h2 class="{{ include.type }}-subheading">{{ page.subtitle }}</h2> <h2 class="{{ include.type }}-subheading">{{ page.subtitle | strip_html }}</h2>
{% endif %} {% endif %}
{% endif %} {% endif %}

View file

@ -11,7 +11,7 @@
var searchjson = '[ \ var searchjson = '[ \
{% for post in site.posts %} \ {% for post in site.posts %} \
{ \ { \
"title" : "{% if post.title != "" %}{{ post.title | escape }}{% else %}{{ post.excerpt | strip_html | escape | strip }}{%endif%}", \ "title" : "{% if post.title != "" %}{{ post.title | strip_html | escape }}{% else %}{{ post.excerpt | strip_html | escape | strip }}{%endif%}", \
"category" : "{{ post.tags | join: \', \' }}", \ "category" : "{{ post.tags | join: \', \' }}", \
"url" : "{{ site.baseurl }}{{ post.url }}", \ "url" : "{{ site.baseurl }}{{ post.url }}", \
"date" : "{{ post.date | date: "%B %e, %Y" | default: "January 1, 1970" }}" \ "date" : "{{ post.date | date: "%B %e, %Y" | default: "January 1, 1970" }}" \
@ -19,7 +19,7 @@
{% endfor %} \ {% endfor %} \
{% for page in site.html_pages %}{% if page.title != "{title}" and page.title != "404 - Page not found" %} \ {% for page in site.html_pages %}{% if page.title != "{title}" and page.title != "404 - Page not found" %} \
{ \ { \
"title" : "{% if page.title != "" %}{{ page.title | escape }}{% else %}{{ page.excerpt | strip_html | escape | strip }}{% endif %}", \ "title" : "{% if page.title != "" %}{{ page.title | strip_html | escape }}{% else %}{{ page.excerpt | strip_html | escape | strip }}{% endif %}", \
"category" : "{% if page.tags %}{{ page.tags | join: \', \' }}{% else %}page{% endif %}", \ "category" : "{% if page.tags %}{{ page.tags | join: \', \' }}{% else %}page{% endif %}", \
"url" : "{{ site.baseurl }}{{ page.url }}", \ "url" : "{{ site.baseurl }}{{ page.url }}", \
"date" : "{{ page.date | date: '%B %e, %Y' | default: "January 1, 1970" }}" \ "date" : "{{ page.date | date: '%B %e, %Y' | default: "January 1, 1970" }}" \

View file

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

View file

@ -35,11 +35,11 @@ layout: page
{% endif %} {% endif %}
<a href="{{ post.url | absolute_url }}"> <a href="{{ post.url | absolute_url }}">
<h2 class="post-title">{{ post.title }}</h2> <h2 class="post-title">{{ post.title | strip_html }}</h2>
{% if post.subtitle %} {% if post.subtitle %}
<h3 class="post-subtitle"> <h3 class="post-subtitle">
{{ post.subtitle }} {{ post.subtitle | strip_html }}
</h3> </h3>
{% endif %} {% endif %}
</a> </a>
@ -68,7 +68,7 @@ layout: page
<div class="post-entry"> <div class="post-entry">
{% assign excerpt_length = site.excerpt_length | default: 50 %} {% assign excerpt_length = site.excerpt_length | default: 50 %}
{{ post.excerpt | strip_html | xml_escape | truncatewords: excerpt_length }} {{ post.excerpt | strip_html | truncatewords: excerpt_length }}
{% assign excerpt_word_count = post.excerpt | number_of_words %} {% assign excerpt_word_count = post.excerpt | number_of_words %}
{% if post.content != post.excerpt or excerpt_word_count > excerpt_length %} {% if post.content != post.excerpt or excerpt_word_count > excerpt_length %}
<a href="{{ post.url | absolute_url }}" class="post-read-more">[Read&nbsp;More]</a> <a href="{{ post.url | absolute_url }}" class="post-read-more">[Read&nbsp;More]</a>

View file

@ -67,12 +67,12 @@ layout: base
<ul class="pagination blog-pager"> <ul class="pagination blog-pager">
{% if page.previous.url %} {% if page.previous.url %}
<li class="page-item previous"> <li class="page-item previous">
<a class="page-link" href="{{ page.previous.url | relative_url }}" data-toggle="tooltip" data-placement="top" title="{{page.previous.title}}">&larr; Previous Post</a> <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>
</li> </li>
{% endif %} {% endif %}
{% if page.next.url %} {% if page.next.url %}
<li class="page-item next"> <li class="page-item next">
<a class="page-link" href="{{ page.next.url | relative_url }}" data-toggle="tooltip" data-placement="top" title="{{page.next.title}}">Next Post &rarr;</a> <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>
</li> </li>
{% endif %} {% endif %}
</ul> </ul>

View file

@ -1,14 +1,14 @@
--- ---
layout: post layout: post
title: Flake it till you make it title: "Flake it & un + he`<i>AA</i>`y <i>BB</i> : per g > % cent ' till y\"ou make it"
subtitle: Excerpt from Soulshaping by Jeff Brown subtitle: "Excerpt from \"Soul<i>ITTT</i>shaping by Jeff Brown"
cover-img: /assets/img/path.jpg cover-img: /assets/img/path.jpg
thumbnail-img: /assets/img/thumb.png thumbnail-img: /assets/img/thumb.png
share-img: /assets/img/path.jpg share-img: /assets/img/path.jpg
tags: [books, test] tags: [books, test]
--- ---
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? 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?
The truth is that no one else can definitively know the path we are here to walk. Its tempting to listen—many of us long for the omnipotent other—but unless they are genuine psychic intuitives, they cant know. All others can know is their own truth, and if theyve actually done the work to excavate it, they will have the good sense to know that they cannot genuinely know anyone elses. 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. The truth is that no one else can definitively know the path we are here to walk. Its tempting to listen—many of us long for the omnipotent other—but unless they are genuine psychic intuitives, they cant know. All others can know is their own truth, and if theyve actually done the work to excavate it, they will have the good sense to know that they cannot genuinely know anyone elses. 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.

View file

@ -1,7 +1,7 @@
--- ---
layout: post layout: post
title: Sample blog post title: Sample blog <i>fds</i>post
subtitle: Each post also has a subtitle subtitle: Each post al<i>ITAL</i>so has a subtitle
gh-repo: daattali/beautiful-jekyll gh-repo: daattali/beautiful-jekyll
gh-badge: [star, fork, follow] gh-badge: [star, fork, follow]
tags: [test] tags: [test]

View file

@ -15,9 +15,9 @@ layout: null
{% assign excerpt_length = site.excerpt_length | default: 50 %} {% assign excerpt_length = site.excerpt_length | default: 50 %}
{% for post in site.posts limit:20 %} {% for post in site.posts limit:20 %}
<item> <item>
<title>{{ post.title | xml_escape }}</title> <title>{{ post.title | strip_html | xml_escape }}</title>
<description> <description>
{% if post.subtitle %}{{ post.subtitle | xml_escape }} - {% endif %} {% if post.subtitle %}{{ post.subtitle | strip_html | xml_escape }} - {% endif %}
{{ post.content | strip_html | xml_escape | truncatewords: excerpt_length }} {{ post.content | strip_html | xml_escape | truncatewords: excerpt_length }}
</description> </description>
<pubDate>{{ post.date | date: "%a, %d %b %Y %H:%M:%S %z" }}</pubDate> <pubDate>{{ post.date | date: "%a, %d %b %Y %H:%M:%S %z" }}</pubDate>

View file

@ -25,7 +25,7 @@ title: 'Tag Index'
<div class="post-list"> <div class="post-list">
{%- for post in site.tags[tag] -%} {%- for post in site.tags[tag] -%}
<div class="tag-entry"> <div class="tag-entry">
<a href="{{ post.url | relative_url }}">{{- post.title -}}</a> <a href="{{ post.url | relative_url }}">{{- post.title | strip_html -}}</a>
<div class="entry-date"> <div class="entry-date">
<time datetime="{{- post.date | date_to_xmlschema -}}">{{- post.date | date: date_format -}}</time> <time datetime="{{- post.date | date_to_xmlschema -}}">{{- post.date | date: date_format -}}</time>
</div> </div>