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 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 commented Sep 2, 2019

Pending hexojs/hexo-util#77

@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 force-pushed the url-encoding branch 2 times, most recently from 0f021a6 to 8bffea1 Compare September 27, 2019 05:39
@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
@curbengh curbengh requested a review from a team October 1, 2019 16:05
Copy link
Contributor Author

@curbengh curbengh left a comment

Choose a reason for hiding this comment

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

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

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.

@curbengh curbengh merged commit d2662d4 into hexojs:master Oct 8, 2019
@curbengh curbengh deleted the url-encoding branch October 8, 2019 01:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants