Welcome! » Log In » Create A New Profile

HTML.TargetBlank not working

Posted by registrationsucks 
HTML.TargetBlank not working
April 05, 2017 03:06AM

I am unable to get HTML.TargetBlank working with the latest 4.9.2

I'm going to post some mismatched code from a wrapper class, it's not designed to be run but you'll get the idea

self::$config = HTMLPurifier_Config::createDefault();
self::$config->set('Core.Encoding', 'ISO-8859-1');
self::$config->set('HTML.Doctype', 'HTML 4.01 Transitional');
self::$config->set('Cache.DefinitionImpl', null);
self::$config->set('HTML.AllowedElements', array('a', 'b', 'br', 'em', 'i', 'img', 'li', 'ol', 'p', 'strike', 'strong', 'u', 'ul'));
self::$config->set('HTML.AllowedAttributes', array('a.href', 'a.target', 'img.alt', 'img.height', 'img.src', 'img.width', 'p.style'));
// sent to self::$config->set
array(
'URI.Base' => DOMAIN,
'URI.MakeAbsolute' => true,
'Attr.AllowedFrameTargets' => array('_blank'),
'HTML.TargetBlank' => true,
'AutoFormat.RemoveEmpty' => true
)

target="_blank" is never added.

Re: HTML.TargetBlank not working
April 05, 2017 11:53AM

Hi, was it working with previous versions?

Re: HTML.TargetBlank not working
April 06, 2017 11:38AM

No idea, wasn't using this feature before. This was upgraded from an old 4.0.0 though.

Re: HTML.TargetBlank not working
April 06, 2017 12:59PM

What happens if you remove the entries for HTML.AllowedElements and HTML.AllowedAttributes

Re: HTML.TargetBlank not working
April 06, 2017 10:43PM

It just scrubs out all the html.

Re: HTML.TargetBlank not working
April 07, 2017 01:07AM

Show me the updated code?

Re: HTML.TargetBlank not working
April 11, 2017 01:27AM

sorry for the delay, I'll make a standalone example here soon.

Author:
Your Email:

Subject:

HTML input is enabled. Make sure you escape all HTML and angled brackets with < and >.

Auto-paragraphing is enabled. Double newlines will be converted to paragraphs; for single newlines, use the pre tag.

Allowed tags: a, abbr, acronym, b, blockquote, caption, cite, code, dd, del, dfn, div, dl, dt, em, i, ins, kbd, li, ol, p, pre, s, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, var.

For inputting literal code such as HTML and PHP for display, use CDATA tags to auto-escape your angled brackets, and pre to preserve newlines:

<pre><![CDATA[
Place code here
]]></pre>

Power users, you can hide this notice with:

.htmlpurifier-help {display:none;}

Message: