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

Purifier Config settings not having affect across all classes (e.g. TableDiff) #78

Open
badams opened this issue Dec 16, 2018 · 1 comment
Labels

Comments

@badams
Copy link

badams commented Dec 16, 2018

Seems like the Purifier config is not being passed down to "nested diff instances";
When a document is being processed new HtmlDiff instances and instances of other classes such as TableDiff are created, if the user provides a HTMLPurifier_Config when creating the top level diff its not passed down to any subsequent instances that are created.

For example the following code should ensure the entire document is returned instead of just the body content.

$oldHtml = '<html><head><style>h1 {color: red}</style></head><body><h1>Hello World</h1><p>Testing</p></body></html>';
$newHtml = '<html><head><style>h1 {color: red}</style></head><body><h1>Hello Every Body!</h1><p>Testing</p></body></html>';
$diff = HtmlDiff::create($oldHtml, $newHtml);
$config =  \HTMLPurifier_Config::createDefault();
$config->set('Core.ConvertDocumentToFragment', false);
$diff->setHTMLPurifierConfig($config);
$diff->build();

results in the following:

<h1>Hello <del class="diffmod">World</del><ins class="diffmod">Every Body!</ins></h1><p>Testing</p>

When you would expect the html/head tags to be included in the output.

Stepping through this with xdebug you notice that the PurifierConfig value Core.ConvertDocumentToFragment is set to true (the default value)

@jschroed91 jschroed91 changed the title Purifier Config settings not having affect. Purifier Config settings not having affect across all classes (e.g. TableDiff) Feb 23, 2019
@jschroed91 jschroed91 added the Bug label Feb 23, 2019
@themiddlehalf
Copy link

I don't believe purifier will retain the html/head tags even if this setting is set to false. ezyang/htmlpurifier#250

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants