Skip to content

Commit

Permalink
fix(escapeTags): escape tag which includes line break (#5402)
Browse files Browse the repository at this point in the history
  • Loading branch information
uiolee authored Jan 22, 2024
1 parent e67c1f1 commit b6de85a
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/hexo/post.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ class PostRenderEscape {
* @returns string
*/
escapeAllSwigTags(str: string) {
if (!/(\{\{.+?\}\})|(\{#.+?#\})|(\{%.+?%\})/.test(str)) {
if (!/(\{\{.+?\}\})|(\{#.+?#\})|(\{%.+?%\})/s.test(str)) {
return str;
}
let state = STATE_PLAINTEXT;
Expand Down
18 changes: 18 additions & 0 deletions test/scripts/hexo/post.js
Original file line number Diff line number Diff line change
Expand Up @@ -1396,4 +1396,22 @@ describe('Post', () => {
should.fail();
} catch (err) {}
});

// https://github.com/hexojs/hexo/issues/5401
it('render() - tags in different lines', async () => {
const content = [
'{% link',
'foobar',
'https://hexo.io/',
'tttitle',
'%}'
].join('\n');

const data = await post.render(null, {
content,
engine: 'markdown'
});

data.content.should.eql('<a href="https://hexo.io/" title="tttitle" target="">foobar</a>');
});
});

0 comments on commit b6de85a

Please sign in to comment.