theme-next / hexo-theme-next

Elegant and powerful theme for Hexo.
https://theme-next.org
Other
8.16k stars 2.05k forks source link

Invalid LeanCloud Counter request when page url contains character `&` #1399

Closed EmmetZC closed 4 years ago

EmmetZC commented 4 years ago

If you delete this template, we may close your issue without conducting an investigation. 如果您删除此模版,我们可能会在不进行调查的情况下关闭您的 Issue。

Please check if your Issue fulfills the following requirements. This will guide you to resolve the issue quickly. 请务必确认您在提交此 Issue 前已经查看并完成了下列检查单中的所有事项。这会指导您快速地解决问题。

Issue Checklist


Expected behavior

Get post visit count from leancloud

Actual behavior

Steps to reproduce the behavior

  1. Use leancloud to do visit-count-statistics
  2. Create a post which has & in its url
  3. Visit the post and you'll see you failed fetching the visit-count because your query is not valid json.
  4. Since visit-count-statistics won't work on localhost testing, you may need to deploy it to reproduce the problem.

By the way, the post produces this problem was written long ago, and it worked fine back then. That time I was using NeXT theme v7.2.0. Earlier today, I upgraded NeXT to the latest version and this problem newly appeared.

Environment Information

Node.js and NPM Information

v12.16.1
6.13.4

Package dependencies Information

├── @fortawesome/free-brands-svg-icons@5.9.0
├── @fortawesome/free-regular-svg-icons@5.9.0
├── @fortawesome/free-solid-svg-icons@5.9.0
├── babel-runtime@6.26.0
├── eslint@6.1.0
├── hexo@3.9.0
├── hexo-deployer-git@1. 0.0
├── hexo-fontawesome@2.0.0
├── hexo-generator-archive@0.1.5
├── hexo-generator-category@0.1.3
├── hexo-generator-index@0.2.1
├── hexo-generator-tag@0.2.0
├── hexo-leancloud-counter-security@1.4.0
├── hexo-renderer-ejs@0.3.1
├── hexo-renderer-marked@1.0.1
├── hexo-renderer-stylus@0.3.3
└── hexo-server@0.3.3

Hexo Configuration

url: https://emmetzc.github.io/
root: /
permalink: :year/:month/:day/:title/
permalink_defaults:

new_post_name: :title.md # File name of new posts
default_layout: post
titlecase: false # Transform title into titlecase
external_link: true # Open external links in new tab
filename_case: 0
render_drafts: false
post_asset_folder: false
relative_link: false
future: true
highlight:
  enable: true
  line_number: true
  auto_detect: false
  tab_replace:

NexT Configuration

Other Information

welcome[bot] commented 4 years ago

Thanks for opening this issue, maintainers will get back to you as soon as possible!

stevenjoezhang commented 4 years ago

Please upgrade to Hexo@4 https://github.com/hexojs/hexo/releases/tag/4.0.0 Currently you're using hexo@3.9.0 which does not encode URLs by default

GitHub
hexojs/hexo
A fast, simple & powerful blog framework, powered by Node.js. - hexojs/hexo
EmmetZC commented 4 years ago

Please upgrade to Hexo@4 https://github.com/hexojs/hexo/releases/tag/4.0.0 Currently you're using hexo@3.9.0 which does not encode URLs by default

GitHubhexojs/hexoA fast, simple & powerful blog framework, powered by Node.js. - hexojs/hexo

Upgraded to Hexo@4.2.0 and still not working. Hexo@4 encodes url by default for sure, but character & requires encodeURIComponent() to be encoded properly.

I guess it might be a bad idea to use & in the post path.

GitHub
hexojs/hexo
A fast, simple & powerful blog framework, powered by Node.js. - hexojs/hexo
stevenjoezhang commented 4 years ago

Hexo doesn't seem to recommend using special symbols in post titles: https://github.com/hexojs/hexo/issues/4104 Anyway, I pushed the bugfix using encodeURIComponent to the master branch, you can update and try if this issue is solved. Hexo 4 is not backward compatible with URL encode changes, which makes these encode / decode problems tricky

EmmetZC commented 4 years ago

Yeah, right. Apologies for making this problem. Better not use special characters again in the future.I've tried the latest NexT theme and it works fine.Many thanks for your help.

On Sun, Mar 8, 2020 4:42 AM, Mimi notifications@github.com wrote: Hexo doesn't seem to recommend using special symbols in post titles: hexojs/hexo#4104 Anyway, I pushed the bugfix using encodeURIComponent to the master branch, you can update and try if this issue is solved. Hexo 4 is not backward compatible with URL encode changes, which makes these encode / decode problems tricky

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe.

Best Wishes

(Chi Zhang)张驰 +86 13279345523 西安交通大学 电信学院 Xi'an Jiaotong University The School of Electronic and Information Engineering