hexojs / hexo

A fast, simple & powerful blog framework, powered by Node.js.
https://hexo.io
MIT License
39.28k stars 4.83k forks source link

fix(escapeAllSwigTags): check tag completeness #5395

Closed uiolee closed 8 months ago

uiolee commented 8 months ago

What does it do?

fix #5301 fix https://github.com/hexojs/hexo-renderer-pandoc/issues/60

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

Screenshots

Pull request tasks

github-actions[bot] commented 8 months ago

How to test

git clone -b escape https://github.com/uiolee/hexo.git
cd hexo
npm install
npm test
coveralls commented 8 months ago

Pull Request Test Coverage Report for Build 7554903652


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

💛 - Coveralls
github-actions[bot] commented 8 months ago

flamegraph

https://e0ff35f3f2a7e732fc5b345e0c7af15b02eed7ee-14-hexo.surge.sh/flamegraph.html https://e0ff35f3f2a7e732fc5b345e0c7af15b02eed7ee-16-hexo.surge.sh/flamegraph.html https://e0ff35f3f2a7e732fc5b345e0c7af15b02eed7ee-18-hexo.surge.sh/flamegraph.html

appotry commented 8 months ago

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 commented 8 months ago

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

D-Sketon commented 8 months ago

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 commented 8 months ago

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版本使用了。等待后面修复