I am using Mews HTML Purifier and have it working great!
However, there are a couple of HTML5 elements such as figure that I want to not be stripped out.
I have looked at the docs:
http://htmlpurifier.org/docs/enduser-customize.html
But cannot see any information on adding elements / the full config options for when using the Laravel config file.
I cant find information when setting up the config like this:
return [
'encoding' => 'UTF-8',
'finalize' => true,
'cachePath' => storage_path('app/purifier'),
'settings' => [
'default' => [
'HTML.Doctype' => 'XHTML 1.0 Strict',
'HTML.Allowed' => 'img[alt|src],ul,li,p,br,b,figure',
'CSS.AllowedProperties' => '',
//'AutoFormat.AutoParagraph' => true,
'AutoFormat.RemoveEmpty' => true,
],
'test' => [
'Attr.EnableID' => true
],
"youtube" => [
"HTML.SafeIframe" => 'true',
"URI.SafeIframeRegexp" => "%^(http://|https://|//)(www.youtube.com/embed/|player.vimeo.com/video/)%",
],
],
];
And then using it like:
Purifier::clean($request->content);
Related
I have made a custom palette in tt_content.php and want to add it to all content elements on the appearance tab like this:
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addToAllTCAtypes(
'tt_content',
'--palette--;My Palette;my_palette',
'',
'before:sectionIndex'
);
This works for everything except Grid Elements (gridelements_pi1). How do I make the new palette show up on Grid Elements as well?
The comment from #MathiasBrodala lead me to finding the answer is in the order of extensions.
In this case I needed to add gridelements under suggests in my ext_emconf.php which ensures it will be loaded before my site package.
$EM_CONF[$_EXTKEY] = [
'title' => 'My Package',
'description' => 'TYPO3 Sitepackage',
'category' => 'templates',
'version' => '1.0.0',
'state' => 'stable',
'constraints' => [
'depends' => [
'typo3' => '8.7.0-9.5.99',
'fluid_styled_content' => '8.7.0-9.5.99'
],
'suggests' => [
'gridelements' => '9.3.0-0.0.0',
],
'conflicts' => [
],
],
'uploadfolder' => 0,
'createDirs' => '',
'clearCacheOnLoad' => 1
];
I am using mewebstudio/Purifier in my Laravel project.
I have a custom vue-component <image-slides> which can be created by the user, and a want to store it into database, so
user input example:
<h2>My Title</h2><image-slides images="https://i.imgur.com/123.jpg,https://i.imgur.com/321.jpg"></image-slides><p>some text</p>
when using default Purifier config:
clean('<h2>My Title</h2><image-slides images="https://i.imgur.com/123.jpg,https://i.imgur.com/321.jpg"></image-slides><p>some text</p>');
=> "<h2>My Title</h2><p>some text</p>"
I add the <image-slides> to the config/purifier.php
return [
'encoding' => 'UTF-8',
'finalize' => true,
'ignoreNonStrings' => false,
'cachePath' => storage_path('app/purifier'),
'cacheFileMode' => 0755,
'settings' => [
'default' => [
'HTML.Doctype' => 'XHTML 1.0 Transitional',
// before
'HTML.Allowed' => 'div,b,strong,i,em,a[href|title],ul,ol,ol[start],li,p[style],br,span[style],img[width|height|alt|src],*[style|class],pre,hr,code,h2,h3,h4,h5,h6,blockquote,del,table,thead,tbody,tr,th,td',
// after
'HTML.Allowed' => 'div,b,strong,i,em,a[href|title],ul,ol,ol[start],li,p[style],br,span[style],img[width|height|alt|src],*[style|class],pre,hr,code,h2,h3,h4,h5,h6,blockquote,del,table,thead,tbody,tr,th,td,image-slides[images]',
...
But I got error:
Element 'image-slides' is not supported (for information on implementing this, see the support forums)
I already clean the cache for both laravel and purifier(remove /storage/app/purifier folder)
How can I add a custom tag for Purifier?
just define it in config/purifier.php
return [
'settings' => [
'default' => [
'HTML.Allowed' => 'image-slide[images]'
],
'custom_elements' => [
['image-slides', 'Block', 'Flow', 'Common', [
'images' => 'Text'
]]
]
]
];
When I'm using rendermode selectTree for my kategorie selection, then I've got an graphical bug. The bug independent from browser (tested in chrome and firefox). I found out, that it looks like the svg icon I'm using for this type.
My tca config for the field "eltern":
'eltern' => [
'exclude' => true,
'label' => 'Eltern',
'config' => [
'type' => 'select',
'renderType' => 'selectTree',
'foreign_table' => 'tx_adressen_domain_model_adresskategorie',
'foreign_table_where' => 'ORDER BY tx_adressen_domain_model_adresskategorie.kategoriename',
'size' => 20,
'treeConfig' => [
'parentField' => 'eltern',
'appearance' => [
'expandAll' => true,
'showHeader' => true,
],
],
'maxitems' => 1,
'minitems' => 0,
],
],
Resolved the problem with using a 16x16 Pixel PNG icon instead of a svg icon
TCA:
return [
...
'iconfile' => 'EXT:adressen/Resources/Public/Icons/Adresskategorie.png',
...
I have application base on Zend framework 2. I have a form with CSRF field. If I fill the form and submit after around 5 minutes it gives me The form submitted did not originate from the expected site validation error.
So I assumed it might be some issue with session configurations. Then I added options to SessionConfig on module.config.php as follows
'session' => array(
'remember_me_seconds' => 2419200,
'use_cookies' => true,
'cookie_httponly' => true,
'cookie_lifetime' => '2419200',
'gc_maxlifetime' => '2419200'
),
But the problem still exist. Do you know how to fix this issue ?
--Update--
My form class contains the CSRF element as follows,
$this->add(array(
'type' => 'Zend\Form\Element\Csrf',
'name' => 'security',
'options' => array(
'csrf_options' => array(
'timeout' => 20000
)
)
));
None of these seems to work.
The Csrf system under ZendFramework configures the session duration from the parameter stored in the configuration of the Csrf element under the timeout key as shown in the following example :
$form->add([
'type' => Element\Csrf::class,
'name' => 'csrf',
'options' => [
'csrf_options' => [
'timeout' => 600,
],
],
]);
Put the session config under the config key as shown in the following example :
'session' => [
'config' => [
'class' => Zend\Session\Config\SessionConfig::class,
'options' => [
'name' => 'SID',
'use_cookies' => true,
'cookie_httponly' => true,
'remember_me_seconds' => 2419200,
],
],
]
I am using HTMLPurifier and this package for Laravel 5:
https://github.com/mewebstudio/Purifier
However, the docs show to use it like this:
$clean = Purifier::clean($dirty);
and the default config file is:
return [
'encoding' => 'UTF-8',
'finalize' => true,
'cachePath' => storage_path('app/purifier'),
'settings' => [
'default' => [
'HTML.Doctype' => 'XHTML 1.0 Strict',
'HTML.Allowed' => 'img[alt|src],ul,li,p,br,b',
'CSS.AllowedProperties' => '',
//'AutoFormat.AutoParagraph' => true,
'AutoFormat.RemoveEmpty' => true,
],
'test' => [
'Attr.EnableID' => true
],
"youtube" => [
"HTML.SafeIframe" => 'true',
"URI.SafeIframeRegexp" => "%^(http://|https://|//)(www.youtube.com/embed/|player.vimeo.com/video/)%",
],
],
];
This works fine, but I need to do some custom config work to allow the use of some HTML elements, namely the figure element tag.
In the docs for HTMLPurifier and elsewhere it shows doing this for example:
$def->addElement('figure', 'Block', 'Optional: (figcaption, Flow) | (Flow, figcaption) | Flow', 'Common');
$def->addElement('figcaption', 'Inline', 'Flow', 'Common');
But no matter what I try I cannot use the Laravel config file to add new elements. Any help?