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

Misc: add meta generator injection filter #3129

Merged
merged 2 commits into from
Apr 20, 2018
Merged

Misc: add meta generator injection filter #3129

merged 2 commits into from
Apr 20, 2018

Conversation

chawyehsu
Copy link
Contributor

@chawyehsu chawyehsu commented Apr 20, 2018

Thank you for creating a pull request to contribute to Hexo code! Before you open the request please review the following guidelines and tips to help it be more easily integrated:

  • Add test cases for the changes.
  • Passed the CI test.

This implements the meta generator injection feature. For more information, see Miscellaneous section of Hexo 4.0 Roadmap, and hexojs/site#649.

@coveralls
Copy link

coveralls commented Apr 20, 2018

Coverage Status

Coverage increased (+0.007%) to 97.222% when pulling 3ed25c9 on h404bi:feature/meta-generator into 373b9c7 on hexojs:master.

@@ -0,0 +1,18 @@
'use strict';

const rMetaGenerator = /<meta\s+name=['|"]?generator['|"]?/i;
Copy link
Contributor

@segayuu segayuu Apr 20, 2018

Choose a reason for hiding this comment

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

Current code will recognize incorrect expressions as html.

<meta name="generator'>

Also, | is described in the character set, this expression will detect <meta name=|generato |>. Is this just as intended?

Copy link
Contributor

@segayuu segayuu Apr 20, 2018

Choose a reason for hiding this comment

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

I prepared regExp which seems to be able to express the intention of writing regExp.

/<meta\s+name=(["']?)generator\1(?: [^>\n]+)?>/i

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@segayuu Oops, didn't notice that, I took that regExp from hugo. I'll make a tweak. I'm considering to use cheerio to detect this meta tag.

Copy link
Contributor

@segayuu segayuu left a comment

Choose a reason for hiding this comment

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

LGTM

@segayuu segayuu merged commit 30fcc4f into hexojs:master Apr 20, 2018
@chawyehsu
Copy link
Contributor Author

chawyehsu commented Apr 20, 2018

Thanks for review! And the task about this in 4.0 Roadmap could be marked as finished.
cc @NoahDragon

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.

4 participants