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

Has the parsing of tags changed in Hexo v7.1.0? #5401

Closed bianyukun1213 closed 8 months ago

bianyukun1213 commented 8 months ago

Check List

Expected behavior

I use this image masonry tag to insert images in my post.

For example,

{% image_masonry
  "https://my.oss.bucket/an-image.webp |alt text 1|image title 1"
  "https://my.oss.bucket/another-image.webp |alt text 2|image title 2"
%}

should render an image masonry that contains 2 images with args[0] parsed as https://my.oss.bucket/an-image.webp |alt text 1|image title 1 and args[1] parsed as https://my.oss.bucket/another-image.webp |alt text 2|image title 2. It works in Hexo v7.0.0.

Actual behavior

However, in Hexo v7.1.0, the " character in the example above will be escaped to ", causing args[0] to change into "https://my.oss.bucket/an-image.webp and args[1] to change into |alt. Also, there will be args[2], args[3], etc…

Eventually, the image masonry will not be rendered correctly.

How to reproduce?

  1. Download the image masonry tag I mentioned and move it to the scripts directory.
  2. Insert an image masonry into a post, like the example above.
  3. Generate the site.

Is the problem still there under Safe mode?

I don’t know, since “Safe mode” will disable all the scripts. But I think the problem will still be there.

Your Node.js & npm version

v18.19.0
10.3.0

Your Hexo and Plugin version

hexo-site@0.0.0 /user_shares/user_hollis/repos/blog-source/src
├── @minify-html/node@0.15.0
├── cheerio@1.0.0-rc.12
├── crypto-js@4.2.0
├── hexo-abbrlink@2.2.1
├── hexo-deployer-git@4.0.0
├── hexo-draft-tags@0.1.1
├── hexo-filter-nofollow@2.0.2
├── hexo-generator-alias@1.0.0
├── hexo-generator-archive@2.0.0
├── hexo-generator-category@2.0.0
├── hexo-generator-index@3.0.0
├── hexo-generator-searchdb@1.4.1
├── hexo-generator-sitemap@3.0.1
├── hexo-generator-tag@2.0.0
├── hexo-hide-posts@0.4.0
├── hexo-renderer-ejs@2.0.0
├── hexo-renderer-markdown-it@7.1.1
├── hexo-renderer-stylus@3.0.1
├── hexo-server@3.0.0
├── hexo-tag-collapse-spoiler@1.0.0
├── hexo-theme-redefine@2.6.0
├── hexo-wordcount@6.0.1
├── hexo-yam@8.0.0
├── hexo@7.1.0
├── html-minifier-terser@7.2.0
└── moment@2.30.1

Your package.json

{
  "name": "hexo-site",
  "version": "0.0.0",
  "private": true,
  "scripts": {
    "build": "hexo generate",
    "clean": "hexo clean",
    "deploy": "hexo deploy",
    "server": "hexo server"
  },
  "hexo": {
    "version": "7.1.0"
  },
  "dependencies": {
    "@minify-html/node": "^0.15.0",
    "cheerio": "^1.0.0-rc.12",
    "crypto-js": "^4.2.0",
    "hexo": "^7.1.0",
    "hexo-abbrlink": "^2.2.1",
    "hexo-deployer-git": "^4.0.0",
    "hexo-draft-tags": "^0.1.1",
    "hexo-filter-nofollow": "^2.0.2",
    "hexo-generator-alias": "^1.0.0",
    "hexo-generator-archive": "^2.0.0",
    "hexo-generator-category": "^2.0.0",
    "hexo-generator-index": "^3.0.0",
    "hexo-generator-searchdb": "^1.4.1",
    "hexo-generator-sitemap": "^3.0.1",
    "hexo-generator-tag": "^2.0.0",
    "hexo-hide-posts": "^0.4.0",
    "hexo-renderer-ejs": "^2.0.0",
    "hexo-renderer-markdown-it": "^7.1.1",
    "hexo-renderer-stylus": "^3.0.1",
    "hexo-server": "^3.0.0",
    "hexo-tag-collapse-spoiler": "^1.0.0",
    "hexo-theme-redefine": "^2.6.0",
    "hexo-wordcount": "^6.0.1",
    "hexo-yam": "^8.0.0",
    "html-minifier-terser": "^7.2.0",
    "moment": "^2.30.1"
  }
}

Your site's _config.yml (Optional)

No response

Others

No response

D-Sketon commented 8 months ago

Is https://github.com/hexojs/hexo/pull/5395 causing this?

uiolee commented 8 months ago

yes

Is #5395 causing this?

uiolee commented 8 months ago
-{% image_masonry
-  "https://my.oss.bucket/an-image.webp |alt text 1|image title 1"
-  "https://my.oss.bucket/another-image.webp |alt text 2|image title 2"
-%}
+{% image_masonry "https://my.oss.bucket/an-image.webp |alt text 1|image title 1" "https://my.oss.bucket/another-image.webp |alt text 2|image title 2" %}

place them in one line will work in v7.1.0



I have check nunjucks and jinja both support that place {{ }} in different lines. But #5395 broken it.

yoshinorin commented 8 months ago

@bianyukun1213 Just now we published v7.1.1.

https://www.npmjs.com/package/hexo/v/7.1.1

Thank you for your reporting :)