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(csp): ensure charset meta at top of head #449

Merged
merged 1 commit into from May 17, 2024

Conversation

vejja
Copy link
Collaborator

@vejja vejja commented May 10, 2024

Closes #444

Types of changes

  • Bug fix (a non-breaking change which fixes an issue)
  • New feature (a non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Description

Currently we insert the CSP meta tag as the first element, to make sure it is read by the UA as soon as possible.

However the W3C spec for HTML5 mentions that the charset meta tag should be the first in head

This PR ensures that the CSP meta tag is inserted right after the charset meta tag, if it exists.

Checklist:

  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have added tests to cover my changes (if not applicable, please state why)

Copy link

vercel bot commented May 10, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
nuxt-security ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 10, 2024 1:52pm

@vejja vejja requested a review from Baroshem May 10, 2024 13:53
@vejja vejja self-assigned this May 10, 2024
@vejja
Copy link
Collaborator Author

vejja commented May 10, 2024

I'm closing #445 in favour of this version, which is v2-compatible

  • uses the recombineHtml step to generate meta instead of the spSsgHashes step
  • uses regex instead of cheerio, in anticipation of completely dropping cheerio in v2

@vejja vejja marked this pull request as ready for review May 10, 2024 13:57
@vejja vejja linked an issue May 10, 2024 that may be closed by this pull request
@frederikheld
Copy link

Thank you very much! ♥

Copy link
Owner

@Baroshem Baroshem left a comment

Choose a reason for hiding this comment

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

Looks great! Thank you for this bugfix. Now we will have another issue solved ;)

You can safely merge to RC branch ⚡️

@vejja vejja merged commit 6c8d01f into chore/2.0.0-rc.1 May 17, 2024
3 checks passed
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.

Move meta charset back to top
3 participants