-
Notifications
You must be signed in to change notification settings - Fork 61
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Moodle new Kekule.js Loader Filter problem #269
Comments
Hi @registerme1963, the forum mod in Moodle applies HTML purifier for the post by default, which erases all img tags inserted with Kekule plugin. For a quick (and dirty) workaround, you may modify the a piece of PHP code of Moodle to disable to purifier. In /lib/weblib.php, about line 1709, you may find if (is_purify_html_necessary($text)) {
$text = purify_html($text, $options);
} to: if (is_purify_html_necessary($text)) {
// $text = purify_html($text, $options);
} So that the purifier will be bypassed. Do not forget to change back the code after all chem objects being inserted to forum. |
Thanks it works, but if I change back, all chem objects disappear, it seems that this change needs to be permanent. I will go with this work around till I complete my examination, but this is dangerous for moodle. Need an alternative way. |
After checking the Moodle documents for a while, the better and official solution is to turn on the |
I saw that, but it is not possible for moodle admin to enable one by one on individual requests. Why not have some regex pattern like |
something like The image from kekule editor gives the following in moodle: |
The trusted Content permission seems to be appliable to user groups, not need to be set to user one by one. And the /lib/weblib.php is within the core modules of Moodle, it is better not to change it from a third-party plugin, :). |
I understand, I'm the admin and also a course teacher, but kekule structure gets stripped for me. Presently I commented out the purify_html line to complete the examination. |
I tried to add student/authenticated roles for trusted content, but still it strips off the kekule structure. So went back and commented out the purify_html line. If this is case, then students cannot use this atto plugin in moodle freely. Do you have any alternate solution without changing the moodle core code |
After checking the HTML purifier code in Moodle for a while, I myself found it was hard coded and unable to be customizable (I'll be very happy if my conclusion is wrong). So you may really have to modify $config->set('URI.AllowedSchemes', array(
'http' => true,
'https' => true,
// ...
'mailto' => true,
'data' => true
)); Down to about line 1862, inside the block of $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'); With all those modifications, do not forget to purge the cache of Moodle. After that, the plugin can work in forum properly with HTML purifier enabled. |
This works throughout the site, thank you. I also submitted your suggestion to Moodle forum to enable custom attributes setting to disable html purifier without editing the core code. I will submit the response here when I get something |
As moodle admin I enabled the filter, and disabled the Kekule.js injector block. The problem comes when I tried to add structure in to forum posts. When I save a forum post after adding the structure from chemeditor, it strips <img tag and kekule-widget text. this seems to happen only in forum post. This did not change even after adding hidden injector block in the course.
As exams are scheduled from today evening onwards, I need some immediate solution.
Thanks for your cooperation
regards
The text was updated successfully, but these errors were encountered: