Purify_html with third party plugins

Purify_html with third party plugins

by R V Iyengar -
Number of replies: 0

I'm on moodle 3.11.4, and using kekulejs (https://github.com/partridgejiang/Kekule.js) atto editor plugin to generate chemical structures. This generates base64 image tag and custom class attributes. However, all these tags are stripped off because of purify_html for students. After enabling trusted content, I tried to allowed for students in my course. However, it did not work. After contacting the plugin author I was told that the HTML purifier code is hard-coded. He suggested the following work-around by editing /lib/weblib.php

$config->set('URI.AllowedSchemes', array(
  'http' => true,
  'https' => true,
  // ...
  'mailto' => true,
  'data' => true
));

and in the block
if ($def = $config->maybeGetRawHTMLDefinition())

$def->addAttribute('img', 'data-chem-obj', 'Text');
$def->addAttribute('img', 'data-kekule-widget', 'Text');
$def->addAttribute('img', 'data-render-type', 'Text');
$def->addAttribute('img', 'data-draw-options', 'Text');
$def->addAttribute('img', 'data-predefined-setting', 'Text');
$def->addAttribute('img', 'data-auto-size', 'Text');
$def->addAttribute('img', 'data-autofit', 'Text');
$def->addAttribute('img', 'data-background-color', 'Text');
$def->addAttribute('img', 'style', 'Text');
$def->addAttribute('img', 'class', 'Text');
$def->addAttribute('img', 'width', 'Text');
$def->addAttribute('img', 'height', 'Text');

after this moodle core modification it works
Is there any option to add such custom attributes without modifying Moodle core code? 
rV

Average of ratings: -