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

body element removed #432

Open
simonLeary42 opened this issue Jan 9, 2025 · 3 comments
Open

body element removed #432

simonLeary42 opened this issue Jan 9, 2025 · 3 comments

Comments

@simonLeary42
Copy link
Contributor

simonLeary42 commented Jan 9, 2025

input:

<html>
  <body style="color:white; background-color:black">
    <p>hello, world!</p>
  </body>
</html>

output:

    <p>hello, world!</p>

is it possible to configure htmlpurifier to allow the body element?

edit: the original output I included was modified by my web browser, I got the actual purifier output with print debugging

@simonLeary42
Copy link
Contributor Author

simonLeary42 commented Jan 9, 2025

setting Core.ConvertDocumentToFragment to false makes no difference. But the description of this option sounds like exactly what I'm looking for:

This parameter determines whether or not the filter should convert input that is a full document with html and body tags to a fragment of just the contents of a body tag. This parameter is simply something HTML Purifier can do during an edge-case: for most inputs, this processing is not necessary.

@simonLeary42
Copy link
Contributor Author

added a print statement into the source code and it definitely isn't executing this code block but it definitely is still extracting the body some other way:

	// extract body from document if applicable
        if ($config->get('Core.ConvertDocumentToFragment')) {
            $e = false;
            if ($config->get('Core.CollectErrors')) {
                $e =& $context->get('ErrorCollector');
            }
            $new_html = $this->extractBody($html);
            if ($e && $new_html != $html) {
                $e->send(E_WARNING, 'Lexer: Extracted body');
            }
            $html = $new_html;
        }

@simonLeary42
Copy link
Contributor Author

simonLeary42 commented Jan 9, 2025

#7

while I am trying to purify an entire document, this issue doesn't mention the <body> tag. It would seem that the <body> tag is lumped in with <html> and <head> as not supported, but I could just be doing it wrong.

@simonLeary42 simonLeary42 changed the title style stripped from body element body element removed Jan 9, 2025
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

No branches or pull requests

1 participant