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

Remove invalid elements from <head> when serializing #424

Open
wwilsman opened this issue Jul 22, 2020 · 2 comments
Open

Remove invalid elements from <head> when serializing #424

wwilsman opened this issue Jul 22, 2020 · 2 comments
Labels
✨ enhancement New feature or request

Comments

@wwilsman
Copy link
Contributor

It's fairly common for some advertising or tracking scripts to inject content into the head such as iframes or images. iframes are allowed in head elements if they themselves only contain meta content elements, but otherwise anything that is not a meta content element is not allowed in a head element.

When re-rendering, browsers insert an implicit </head> before invalid content which pushes any following elements, meta content or not, into the body. Usually resulting in a broken page.

We currently remove all iframes from the head since they do not influence the page visually. There is a very short list of allowed elements in headers. https://developer.mozilla.org/en-US/docs/Web/HTML/Element/head#See_also

Should we start by removing images and eventually expand that to include other common elements? Or should we iterate through head elements and remove any that are not explicitly allowed?

@Robdel12
Copy link
Contributor

@wwilsman I think we took care of this in CLI, right?

@wwilsman
Copy link
Contributor Author

Not entirely. iFrames are removed from head elements but we don't yet prune invalid content

@wwilsman wwilsman transferred this issue from percy/percy-agent Jul 16, 2021
@wwilsman wwilsman added the ✨ enhancement New feature or request label Jul 16, 2021
samarsault pushed a commit that referenced this issue Mar 3, 2023
Bumps [cypress](https://github.com/cypress-io/cypress) from 8.5.0 to 8.6.0.
- [Release notes](https://github.com/cypress-io/cypress/releases)
- [Changelog](https://github.com/cypress-io/cypress/blob/develop/.releaserc.base.js)
- [Commits](cypress-io/cypress@v8.5.0...v8.6.0)

---
updated-dependencies:
- dependency-name: cypress
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
✨ enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants