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(open_graph): percent-encode url, not html escape #3686

Merged
merged 10 commits into from Oct 8, 2019

Conversation

@curbengh
Copy link
Contributor

@curbengh curbengh commented Aug 24, 2019

root/path value should be percent-encoded, not html escaped.

What does it do?

_config.yml
url: https://日本語テストgôg.com/hexô-testing

Current behavior

<meta property="og:url" content="https://&#x65E5;&#x672C;&#x8A9E;&#x30C6;&#x30B9;&#x30C8;g&#xF4;g.com/hex&#xF4;-testing/index.html">

Expected behavior

<meta property="og:url" content="https://xn--gg-8ja8200c3ban0926g0ecl32k.com/hex%C3%B4-testing/index.html">

How to test

git clone -b url-encoding https://github.com/curbengh/hexo.git
cd hexo
npm install
npm test

Pull request tasks

  • Add test cases for the changes.
  • Passed the CI test.
@coveralls
Copy link

@coveralls coveralls commented Aug 24, 2019

Coverage Status

Coverage decreased (-0.002%) to 97.297% when pulling 6f7fe0c on curbengh:url-encoding into 18d459f on hexojs:master.

@curbengh
Copy link
Contributor Author

@curbengh curbengh commented Sep 2, 2019

@curbengh curbengh changed the title fix(open_graph): support IDN url fix(open_graph): encode url Sep 26, 2019
@curbengh curbengh added this to the v4.0.0 milestone Sep 26, 2019
@curbengh curbengh added this to In progress in v4.0.0 via automation Sep 26, 2019
@curbengh curbengh moved this from In progress to To do in v4.0.0 Sep 26, 2019
@curbengh curbengh force-pushed the url-encoding branch 2 times, most recently from 0f021a6 to 8bffea1 Sep 27, 2019
@curbengh curbengh changed the title fix(open_graph): encode url fix(open_graph): root/path value should be percent-encoded, not html escaped. Sep 27, 2019
@curbengh curbengh changed the title fix(open_graph): root/path value should be percent-encoded, not html escaped. fix(open_graph): percent-encode url, not html escape Sep 27, 2019
test/scripts/helpers/open_graph.js Outdated Show resolved Hide resolved
@curbengh curbengh requested a review from Oct 1, 2019
Copy link
Contributor Author

@curbengh curbengh left a comment

comment removed

@@ -41,7 +41,7 @@ describe('asset_img', () => {
});

it('default', () => {
assetImg('bar title').should.eql('<img src="/foo/bar" class="" title="title">');
assetImg('bar "a title"').should.eql('<img src="/foo/bar" class="" title="a title">');
Copy link
Contributor Author

@curbengh curbengh Oct 8, 2019

Choose a reason for hiding this comment

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

@SukkaW

hexojs/hexo-util@622167f could have undesired output when

htmlTag('a', { src: '/foo/', title: 'title', alt: 'alt' }, 'text')

title and alt are incorrectly seen as boolean. It's a very rare edge case (title="title" is valid but bad practice), so I don't mind keeping hexojs/hexo-util@622167f, just fyi.

v4.0.0 automation moved this from To do to In progress Oct 8, 2019
SukkaW
SukkaW approved these changes Oct 8, 2019
@curbengh curbengh merged commit d2662d4 into hexojs:master Oct 8, 2019
3 of 4 checks passed
v4.0.0 automation moved this from In progress to Done Oct 8, 2019
@curbengh curbengh deleted the url-encoding branch Oct 8, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
v4.0.0
  
Done
Linked issues

Successfully merging this pull request may close these issues.

None yet

3 participants