dcd1f5d48c
Here we go, next step then. As we did not fix the performance issue when autofiltering the variables (see bug 20975), the only solution we have is to add the filters explicitely. This patch has been autogenerated (using add_html_filters.pl, see next pathces) and add the html filter to all the variables displayed in the template. Exceptions are made (using the new 'raw' TT filter) to the variable we already listed in the previous versions of this patch. To test: - Use t/db_dependent/Koha/Patrons.t to populate your DB with autogenerated data which contain <script> tags - Remove them from borrower_debarments.comments (there are allowed here) update borrower_debarments set comment="html tags possible here"; - From the interface hit page and try to catch alert box. If you find one it means you find a possible XSS. To know where it comes from: * note the exact URL where you found it * note the alert box content * Dump your DB and search for the string in the dump to identify its location (for instance table.field) Next: * Ideally we would like to use the raw filter when it is not necessary to HTML escape the variables (in big loop for instance) * Provide a QA script to catch missing filters (we want html, uri, url or raw, certainly others that I am forgetting now) * Replace the html filters with uri when needed (!) Signed-off-by: Owen Leonard <oleonard@myacpl.org> Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
60 lines
2.5 KiB
C++
60 lines
2.5 KiB
C++
[% USE raw %]
|
|
[% USE Asset %]
|
|
[% #Enable tinymce for system preferences %]
|
|
[% Asset.js("lib/tiny_mce/tiny_mce.js") | $raw %]
|
|
<script>
|
|
|
|
[%# Save TinyMCE content and trigger an event on the original element %]
|
|
function wysiwyg_change (ed){
|
|
ed.save();
|
|
var original_textarea = ed.getElement();
|
|
$(original_textarea).trigger("input");
|
|
}
|
|
|
|
tinyMCE.baseURL = "[% interface | html %]/lib/tiny_mce";
|
|
tinyMCE.init({
|
|
setup : function(ed) {
|
|
ed.onInit.add(function(editor){
|
|
[%-
|
|
#Ideally, it would be nice just to use the "oninput" event, which captures keyboard input, dragging, pasting, etc.
|
|
#However, it doesn't work in IE when the event listener is for an element which is "contenteditable". Since TinyMCE
|
|
#uses a "contenteditable" body element in an iframe element, it's never going to fire in IE.
|
|
|
|
#We can get around this a bit by using "onkeyup" and "ondragend".
|
|
|
|
#"ondragend" occurs after you drag content within the editor. "ondrop" is for when you drag content from outside the
|
|
#editor but it doesn't "dirty" the editor, which makes it useless, as the editor won't save unless it's dirty.
|
|
#"onpaste" is useless in this same way.
|
|
|
|
#Reference:
|
|
#https://developer.mozilla.org/en-US/docs/Web/Events/input
|
|
#https://connect.microsoft.com/IE/feedbackdetail/view/794285
|
|
-%]
|
|
|
|
tinyMCE.dom.Event.bind(editor.getBody(), 'input keyup dragend', function(e){
|
|
wysiwyg_change(ed);
|
|
});
|
|
});
|
|
|
|
// Register change when TinyMCE command returns isDirty()
|
|
ed.onExecCommand.add(function(ed, cmd, ui, val) {
|
|
wysiwyg_change(ed);
|
|
});
|
|
|
|
},
|
|
mode : "specific_textareas",
|
|
editor_selector : "mce",
|
|
theme : "advanced",
|
|
content_css : "[% interface | html %]/[% theme | html %]/css/tinymce.css",
|
|
plugins : "table,save,advhr,advlink,contextmenu,advimage",
|
|
theme_advanced_buttons1 : "bold,italic,|,cut,copy,paste,|,justifyleft,justifycenter,justifyright,justifyfull,|,formatselect,|,image,link,unlink,anchor,cleanup,help,code,advhr,",
|
|
theme_advanced_buttons2 : "tablecontrols,|,bullist,numlist,|,outdent,indent,|,undo,redo,|,removeformat,|,visualaid,|,sub,sup,|,charmap|,forecolor,backcolor",
|
|
theme_advanced_buttons3 : "",
|
|
theme_advanced_toolbar_location : "top",
|
|
theme_advanced_toolbar_align : "left",
|
|
theme_advanced_path_location : "bottom",
|
|
theme_advanced_resizing : true,
|
|
apply_source_formatting : true
|
|
});
|
|
//]]>
|
|
</script>
|