-
Notifications
You must be signed in to change notification settings - Fork 12
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
Question: is it possible to have self-closing tags? #81
Comments
Can you provide a minimal reproduction? Are you sure the right config is used? The following code works as expected (which means that self-closing tags are supported correctly): <?php
require 'vendor/autoload.php';
$config = \HTMLPurifier_HTML5Config::createDefault();
$config->set('HTML.XHTML', true);
$purifier = new \HTMLPurifier($config);
$html = "<img src='test.png'/><hr/><br/>";
echo $purifier->purify($html);
// <img src="test.png" alt="test.png" /><hr /><br /> What does |
Many thanks for your fast feedback. I greatly appreciate your help. I test with your code in my Symfony application, in controller.
It returns html5 with no self-closing tags. I forgot to mention this Symfony Application uses HTMLPurifierBundle HTML5 Doctype registered by this repository contains xml variable, set to false. Should it be turned to true to format HTML with self closing tags ? |
Ok, I think I found the problem. My project uses Composer to install dependency. And documentation says that HTML.XHTML parameter is available since v0.1.12 (Version added: 0.1.12) But Composer does not found this tagged version because it doesn't exist. There's no 0.1.12 version and composer install 0.1.11 instead. I switch your repository to dev-master version and it works!! :) Do you think you could create a new release tagged v0.1.12 ? Many thanks for your help! :) :) |
Yes, exactly! I was testing against I (still) need to make some adjustments before publishing |
Do you need help ? The project is very complex, and I don't know if I could help you. |
Setting HTML.XHTML to true doesn't affect tags, however, it is written in documentation that
I tried to pass this option in Custom HTMLPurifier Class:
Service :
In Controller, I use the right HTMLPurifier, it's ok. But purify() method do not convert html tags to self-closing tags.
I was expecting that it will return
<img src="test.png" alt="test.png"/><hr/><br/>
Maybe I did not understand what HTML.XHTML is supposed to do
The text was updated successfully, but these errors were encountered: