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 void elements that libxml2 does not know #142

Merged
merged 2 commits into from
Oct 1, 2024

Conversation

krokodok
Copy link
Contributor

@krokodok krokodok commented Sep 3, 2024

libxml2 has some problems with void elements, it does not know. In these cases, it will add stray end tags that are not needed.

The missing elements are:

  • embed
  • source
  • track
  • wbr

In most cases, this does not lead to visible problems because browsers will still be able to interpret the source code correctly. However, this still leads to invalid HTML and is not a desired side effect of our plugin.

The easiest, straight-forward approach would be just removing the stray end tags afterwards.

Reproduction

  • Create a new WordPress post and add <source> to the content.
  • You will see in the source code that a stray end tag was added.
  • With this feature branch the end tag should be correctly removed again.

@krokodok krokodok self-assigned this Sep 3, 2024
Comment on lines 166 to 169
'</embed>',
'</source>',
'</track>',
'</wbr>',
Copy link
Member

Choose a reason for hiding this comment

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

Let's extend the existing str_replace() call with these tags, you can update the comment as well.

@krokodok krokodok merged commit d1bc811 into master Oct 1, 2024
1 of 3 checks passed
@krokodok krokodok deleted the feature/fix-stray-end-tags branch October 1, 2024 07:59
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.

2 participants