htmlpurifier

Allow custom url's in src for image in htmlpurifier


I am having a problem with HTMLPurifier settings.

In my case the HTML that i am trying to purify contains img tags. To allow this I added:

$config->set('HTML.Allowed', 'p[align|style],strong,a[href|title|mailto],em,table[class|width|cellpadding],td,tr,h3,h4,h5,hr,br,u,ul,ol,li,img[src|width|height|alt|class],span[class],strike,sup,sub');

to my config.

But the problem is that the src value for my images begin and end with %%abc%% %%xyz%% respectively. I use these strings later in my code to identify the image urls and do some stuff.

But HTMLPurifier is not allowing these types of url.

I tried adding a custom URI schema, but I am not able to get it to work. Any help is appreciated .


Solution

  • Hmmm... yeah, you're probably kind of out of luck, unless you regex out the custom values and leave a unique identifier in its place, and then splat them back in at the end. Percent signs are particularly bad, because they normally have different meaning in URLs.