Reputation: 1659
I am trying to disable hyperlinks and show them in plain text using HTMLPurifier but I did not get right. Here is my code:
$html ='<a href="http://www.localhost.com/">link</a><b>test</b>';
require_once 'include/htmlpurifier/library/HTMLPurifier.auto.php';
$Config = HTMLPurifier_Config::createDefault();
$Config->set('AutoFormat.DisplayLinkURI', true);
$purifier = new HTMLPurifier();
$html = $purifier->purify($html);
echo $html;
The current output is:
<a href="http://www.localhost.com/">link</a><b>test</b>
What is the problem? The output should be:
<a>link</a> (http://www.localhost.com/)<b>test</b>
Upvotes: 0
Views: 425
Reputation: 26762
First problem: you're not passing the config object to the HTML Purifier constructor, so it doesn't work.
Second problem: you haven't actually told HTML Purifier to remove href attributes from a tags. I'm not really sure what will happen to DisplayLinkURI if you do that though.
Upvotes: 2