Skip to content

Commit

Permalink
fix: missing xml escape for alt of preview image (#1113)
Browse files Browse the repository at this point in the history
Preview image display error when `alt` contains '<' or '>'


Co-authored-by: Cotes Chung <11371340+cotes2020@users.noreply.github.com>
  • Loading branch information
PENEKhun and cotes2020 committed Jun 28, 2023
1 parent 2639f8e commit 8b0fbf5
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion _layouts/home.html
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
{% assign src = post.img_path | append: '/' | append: src | replace: '//', '/' %}
{% endunless %}

{% assign alt = post.image.alt | default: 'Preview Image' %}
{% assign alt = post.image.alt | xml_escape | default: 'Preview Image' %}

<img src="{{ src }}" w="17" h="10" alt="{{ alt }}" {{ lqip }}>
{% endif %}
Expand Down
2 changes: 1 addition & 1 deletion _layouts/post.html
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ <h1 data-toc-skip>{{ page.title }}</h1>
{% if page.image %}
{% capture src %}src="{{ page.image.path | default: page.image }}"{% endcapture %}
{% capture class %}class="preview-img{% if page.image.no_bg %}{{ ' no-bg' }}{% endif %}"{% endcapture %}
{% capture alt %}alt="{{ page.image.alt | default: "Preview Image" }}"{% endcapture %}
{% capture alt %}alt="{{ page.image.alt | xml_escape | default: "Preview Image" }}"{% endcapture %}

{% capture lqip %}
{% if page.image.lqip %}
Expand Down

0 comments on commit 8b0fbf5

Please sign in to comment.