Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(escapeAllSwigTags): check tag completeness #5395

Merged
merged 3 commits into from
Jan 18, 2024
Merged

fix(escapeAllSwigTags): check tag completeness #5395

merged 3 commits into from
Jan 18, 2024

Conversation

uiolee
Copy link
Member

@uiolee uiolee commented Jan 14, 2024

What does it do?

fix #5301
fix hexojs/hexo-renderer-pandoc#60

Before escape tags, check if it contains a complete tag.
In others words, just escape complete tags.

Screenshots

Pull request tasks

  • Add test cases for the changes.
  • Passed the CI test.

Copy link

How to test

git clone -b escape https://github.com/uiolee/hexo.git
cd hexo
npm install
npm test

@coveralls
Copy link

coveralls commented Jan 14, 2024

Pull Request Test Coverage Report for Build 7554903652

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage decreased (-0.02%) to 99.519%

Totals Coverage Status
Change from base Build 7499174786: -0.02%
Covered Lines: 9099
Relevant Lines: 9143

💛 - Coveralls

@uiolee uiolee requested a review from SukkaW January 14, 2024 07:48
lib/hexo/post.ts Outdated
state = STATE_SWIG_VAR;
idx++;
} else if (next_char === '#') {
} else if (next_char === '#' && /\{#.+?#\}/.test(str)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With the change, we will run regexp.test again and again for every character inside str.

The .test should be hoist to the top of the function.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks, I have updated it

@uiolee uiolee requested a review from SukkaW January 17, 2024 11:53
@uiolee uiolee merged commit c1c5aaa into hexojs:master Jan 18, 2024
20 of 22 checks passed
@appotry
Copy link

appotry commented Jan 21, 2024

7.1 没有完全修复,解析下面代码会报错。7.0 反而解析正常。

Version 7.1 is not fully fixed; parsing the following code will result in an error. Surprisingly, parsing is normal in version 7.0

{% valkyrurl
[url=/posts/f4926c88/]
[title="RSS的使用与Tiny Tiny RSS Selfhost自建"]
[avatar=/medias_webp/cover/rss.webp]
[desc="RSS是一种消息来源的格式规范,网站可以按照这种格式规范提供文章的标题、摘要、全文等信息给订阅用户,用户可以通过订阅不同网站 RSS 链接的方式将不同的信息源进行聚合,在一个工具里阅读这些内容"]
%}

err log

13:09:23.020 FATAL Something's wrong. Maybe you can find the solution here: https://hexo.io/docs/troubleshooting.html
Template render error: (unknown path)
  TypeError: Cannot read properties of null (reading '1')
    at Object._prettifyError (/app/node_modules/nunjucks/src/lib.js:32:11)
    at /app/node_modules/nunjucks/src/environment.js:464:19
    at eval (eval at _compile (/app/node_modules/nunjucks/src/environment.js:527:18), <anonymous>:11:11)
    at tryCatcher (/app/node_modules/bluebird/js/release/util.js:16:23)
    at Promise._settlePromiseFromHandler (/app/node_modules/bluebird/js/release/promise.js:547:31)
    at Promise._settlePromise (/app/node_modules/bluebird/js/release/promise.js:604:18)
    at Promise._settlePromiseCtx (/app/node_modules/bluebird/js/release/promise.js:641:10)
    at _drainQueueStep (/app/node_modules/bluebird/js/release/async.js:97:12)
    at _drainQueue (/app/node_modules/bluebird/js/release/async.js:86:9)
    at Async._drainQueues (/app/node_modules/bluebird/js/release/async.js:102:5)
    at Async.drainQueues (/app/node_modules/bluebird/js/release/async.js:15:14)
    at process.processImmediate (node:internal/timers:478:21)

@appotry
Copy link

appotry commented Jan 21, 2024

7.1版本不止上面这一个tag 报错,7.0反而正常

@D-Sketon
Copy link
Member

D-Sketon commented Jan 21, 2024

7.1 没有完全修复,解析下面代码会报错。7.0 反而解析正常。

Version 7.1 is not fully fixed; parsing the following code will result in an error. Surprisingly, parsing is normal in version 7.0

{% valkyrurl
[url=/posts/f4926c88/]
[title="RSS的使用与Tiny Tiny RSS Selfhost自建"]
[avatar=/medias_webp/cover/rss.webp]
[desc="RSS是一种消息来源的格式规范,网站可以按照这种格式规范提供文章的标题、摘要、全文等信息给订阅用户,用户可以通过订阅不同网站 RSS 链接的方式将不同的信息源进行聚合,在一个工具里阅读这些内容"]
%}

err log

13:09:23.020 FATAL Something's wrong. Maybe you can find the solution here: https://hexo.io/docs/troubleshooting.html
Template render error: (unknown path)
  TypeError: Cannot read properties of null (reading '1')
    at Object._prettifyError (/app/node_modules/nunjucks/src/lib.js:32:11)
    at /app/node_modules/nunjucks/src/environment.js:464:19
    at eval (eval at _compile (/app/node_modules/nunjucks/src/environment.js:527:18), <anonymous>:11:11)
    at tryCatcher (/app/node_modules/bluebird/js/release/util.js:16:23)
    at Promise._settlePromiseFromHandler (/app/node_modules/bluebird/js/release/promise.js:547:31)
    at Promise._settlePromise (/app/node_modules/bluebird/js/release/promise.js:604:18)
    at Promise._settlePromiseCtx (/app/node_modules/bluebird/js/release/promise.js:641:10)
    at _drainQueueStep (/app/node_modules/bluebird/js/release/async.js:97:12)
    at _drainQueue (/app/node_modules/bluebird/js/release/async.js:86:9)
    at Async._drainQueues (/app/node_modules/bluebird/js/release/async.js:102:5)
    at Async.drainQueues (/app/node_modules/bluebird/js/release/async.js:15:14)
    at process.processImmediate (node:internal/timers:478:21)

#5401,和换行有关

@appotry
Copy link

appotry commented Jan 21, 2024

7.1 没有完全修复,解析下面代码会报错。7.0 反而解析正常。
Version 7.1 is not fully fixed; parsing the following code will result in an error. Surprisingly, parsing is normal in version 7.0

{% valkyrurl
[url=/posts/f4926c88/]
[title="RSS的使用与Tiny Tiny RSS Selfhost自建"]
[avatar=/medias_webp/cover/rss.webp]
[desc="RSS是一种消息来源的格式规范,网站可以按照这种格式规范提供文章的标题、摘要、全文等信息给订阅用户,用户可以通过订阅不同网站 RSS 链接的方式将不同的信息源进行聚合,在一个工具里阅读这些内容"]
%}

err log

13:09:23.020 FATAL Something's wrong. Maybe you can find the solution here: https://hexo.io/docs/troubleshooting.html
Template render error: (unknown path)
  TypeError: Cannot read properties of null (reading '1')
    at Object._prettifyError (/app/node_modules/nunjucks/src/lib.js:32:11)
    at /app/node_modules/nunjucks/src/environment.js:464:19
    at eval (eval at _compile (/app/node_modules/nunjucks/src/environment.js:527:18), <anonymous>:11:11)
    at tryCatcher (/app/node_modules/bluebird/js/release/util.js:16:23)
    at Promise._settlePromiseFromHandler (/app/node_modules/bluebird/js/release/promise.js:547:31)
    at Promise._settlePromise (/app/node_modules/bluebird/js/release/promise.js:604:18)
    at Promise._settlePromiseCtx (/app/node_modules/bluebird/js/release/promise.js:641:10)
    at _drainQueueStep (/app/node_modules/bluebird/js/release/async.js:97:12)
    at _drainQueue (/app/node_modules/bluebird/js/release/async.js:86:9)
    at Async._drainQueues (/app/node_modules/bluebird/js/release/async.js:102:5)
    at Async.drainQueues (/app/node_modules/bluebird/js/release/async.js:15:14)
    at process.processImmediate (node:internal/timers:478:21)

#5401,和换行有关

那个issue看过,找到这里来的

文章太多,不可能一个个tag修改过去, 只能先降级到7.0版本使用了。等待后面修复

@uiolee uiolee mentioned this pull request Nov 3, 2024
5 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
5 participants