Skip to content

Commit

Permalink
fix(post): escape swig full tag with args (#4824)
Browse files Browse the repository at this point in the history
  • Loading branch information
stevenjoezhang authored Nov 23, 2021
1 parent 902cd70 commit 3ed6fd9
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
5 changes: 4 additions & 1 deletion lib/hexo/post.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ class PostRenderEscape {
let output = '';

let swig_tag_name_begin = false;
let swig_tag_name_end = false;
let swig_tag_name = '';
let swig_full_tag_start_buffer = '';

Expand All @@ -93,6 +94,7 @@ class PostRenderEscape {
swig_tag_name = '';
swig_full_tag_start_buffer = '';
swig_tag_name_begin = false; // Mark if it is the first non white space char in the swig tag
swig_tag_name_end = false;
} else {
output += char;
}
Expand All @@ -116,7 +118,7 @@ class PostRenderEscape {
swig_full_tag_start_buffer = swig_full_tag_start_buffer + char;

if (isNonWhiteSpaceChar(char)) {
if (!swig_tag_name_begin) {
if (!swig_tag_name_begin && !swig_tag_name_end) {
swig_tag_name_begin = true;
}

Expand All @@ -126,6 +128,7 @@ class PostRenderEscape {
} else {
if (swig_tag_name_begin === true) {
swig_tag_name_begin = false;
swig_tag_name_end = true;
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion test/fixtures/post_render.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ exports.expected = [
'<blockquote>',
'<p>quote content 1</p>\n',
'</blockquote>\n\n',
'<blockquote><p>quote content 2</p>',
'<blockquote><p>quote content 2</p>\n',
'<footer><strong>Hello World</strong></footer></blockquote>'
].join('');

Expand Down

0 comments on commit 3ed6fd9

Please sign in to comment.