Is HTML_purifier removing display:none CSS from images, even when CSS.AllowTricky is set to True?

My title might be a bit confusing, so I'll explain further.

I'm using HTML_purifier to sanitize user input, although in this case, the only user will be myself (it's in password-protected folders). To keep it short, I want to be able to add image tag code to a web form and then display that image on the page it sends to. However, I need the image tag to have CSS attributes added to it, specifically

display:block

By default, HTML_purifier removes this due to the CSS.allowTricky option, detailed here. Setting the CSS.allowTricky option to True should allow

display:block

Despite doing this, it's still being removed. Has anyone encountered this before? There isn't much documentation available online. It's not generating any errors in syslog, so I assume the implementation is correct but not working as expected.

My current code looks like this:

include('HTMLPurifier.standalone.php');
$config = HTMLPurifier_Config::createDefault();
$config->set('CSS.AllowTricky', true);

* UPDATE *

The code needs to pass the config object (which has already been set) to the HTML purifier object. Putting it together, it should look something like this:

include('HTMLPurifier.standalone.php');
$config = HTMLPurifier_Config::createDefault();
$config->set('CSS.AllowTricky', true);
$purifier = new HTMLPurifier($config);

Answer №1

This response is a copy of the solution found at this page (the key was to pass the configuration object to HTML Purifier object for proper application).

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Troubleshooting: AngularJS routing issue

I'm facing an issue with my AngularJS routing code. Here is the code snippet: /// <reference path="C:\Users\elwany\documents\visual studio 2015\Projects\spaapplication\spaapplication\scripts/angular.js" /& ...

trigger a CSS animation using JavaScript upon a specified event

I am attempting to incorporate a class for an autogrow animation effect to a textarea element. Here is a demo: http://jsfiddle.net/d0kmg7d3/15/ var tx = document.getElementsByTagName('textarea'); for (var i = 0; i < tx.length; i++) { tx[i] ...

Is it unnecessary to use both "width: inherit" and "float: none

When learning about responsive design, one pattern that is frequently seen is: @media screen and (max-width: 480px){ .class1{ width: inherit; float: none; } .class2{ width: inherit; float: none; } f ...

The buttons in the Bootstrap modal are unresponsive

I'm attempting to create a modal navigation bar for mobile view but encountering an issue. When I click on the icon bar or menu bar in mobile view, none of the buttons inside the modal are responding. I'm quite stuck on this and would appreciate ...

My Jquery code seems to break after the second form submission. Could it be related to Django, Ajax, or Jquery?

I have a toggle button that allows users to follow or unfollow. The jQuery is working on the first submit, but when I toggle the button again, the elements don't change. html {% for user in followers %} <div class="flist" id="fl ...

Having trouble with the link attribute not functioning properly for a radio button in Chrome?

<a> hyperlink for radio button is not functioning correctly in Chrome. Here is the code segment in question: <td width='7%' bgcolor='#E8E8E8'> <a href='issue.php?admin=Yes&&user=$user'> <inp ...

Tips for resolving a flickering issue that occurs when switching to an input field with our default value / placeholder plugin

In the realm of web development, numerous plugins cater to the implementation of HTML5's placeholder attribute in older browsers. The plugin we have opted for can be found here. Unlike some other alternatives, this particular plugin, with a few modif ...

Using a negative mask in CSS when overlaying a background image

Looking to create a unique mask in CSS using a PNG file, but with a twist. Rather than displaying the content underneath, I want the mask to cut out that content and display everything else around it - almost like a negative mask effect. The key requiremen ...

Accessing the value of a span element from the current element using JavaScript/jQuery

I am working with <select> elements that have price information within a span tag for each available option. My goal is to retrieve the value of the span associated with the selected option of each select element. Here is my current code: <select ...

Can one image impact other images through a wrapping function?

I am facing an issue with positioning 3 images independently from the window size using the position: relative declaration. When I try to define positions for the first 2 images and then insert the third one, it disrupts the position of the first two. Is ...

Determine the top margin of an element

Looking to position my text with a 100px top margin, similar to this: Any ideas on accomplishing this? The font size should be 24pt and bold. ...

Error: Selenium unable to find element within specified wait time limit

Appreciate your time, even though it was a bit lengthy. I struggled to find the element using various methods such as setting waits, switching frames, and executing JavaScript. Below is a snippet of the HTML DOM after the page has fully loaded (the conte ...

Troubleshoot: Why is my Bootstrap 3 responsive navigation bar not functioning

When using drop down items that are longer in length, they tend to wrap down to the next level rather than overflowing. I am not well-versed in @media queries, but I've noticed that on mobile devices the dropdown collapses in the navigation menu, whil ...

Is it possible to use powershell to simulate clicking on an angularjs button?

<div class="w-btn" ng-click="vm.callbacks.compareAll();" ng-if="vm.folderData.projects.length > 0 &amp;&amp; vm.noneSelectedProjects" tabindex="0"><i class="glyphicon glyphicon-transfer btn-icon"></i> Report from all</div> ...

I'm experiencing an issue where the Devtool appears empty when inspecting it, making it impossible to locate

I'm currently working on automating the process of entering data into web forms using Selenium VBA. The forms are located on our organization's SharePoint site, and I have already logged into the account. However, every time I reach the final ste ...

Mapping the Way: Innovative Controls for Navigation

Currently, I am utilizing the HERE maps API for JavaScript. However, I would like to customize the design of the map controls similar to this: Below is an example for reference: HERE EXAMPLE Is it feasible to achieve this customization? ...

Using jQuery to vertically center a div

When a vertical menu on my website is clicked, it pops out from the left side of the screen. The content inside is vertically centered using CSS transformations. While expanding to show sub-items, everything remains centered. However, there's an issue ...

Position an element in the middle of the range between the tallest and shortest characters

Is there a way to vertically center an element between the tallest and shortest characters of another element (preferably using just CSS, but JavaScript is also acceptable)? I want it to be aligned with the actual text content rather than the line height, ...

Should we shift the sidebar to the right-hand side of the page? Is this accomplished using a float? Would it be necessary to include

Currently, I am tackling this code: http://jsfiddle.net/4XBtQ/1/ Upon inspection, it is evident that the right sidebar remains at the bottom of the left column. Various methods exist to position the sidebar on the right, but which approach is deemed corr ...

Is it advisable to avoid using inline styles?

Exploring React's Styling and CSS documentation delves into the question of Are inline styles bad? by hinting that CSS classes are preferable for performance, without providing any further elaboration. Looking solely at performance metrics, overlooki ...