philippK-de / Collabtive

Collabtive is web based project management software
https://collabtive.o-dyn.de
GNU General Public License v3.0
215 stars 131 forks source link

New Tasks with Special Characters (Umlauts) not saved properly #126

Closed Trigonometry closed 7 years ago

Trigonometry commented 7 years ago

PHP 5.6.29-0+deb8u1 (cli) (built: Dec 14 2016 13:13:28) mysql Ver 14.14 Distrib 5.5.53 Database: collabtive, collation: utf8_general_ci Collabtive v3.01, Theme: standard, No extensions

Issue 1: Creating a new task cuts of the task text at the first occurrence of an umlaut. German Example: Bitte eine neue Datenbank anlegen für Qualitätsmanagement Saved Result: Bitte eine neue Datenbank anlegen f Database Entry: Bitte eine neue Datenbank anlegen f Editing the existing task and re-inserting the full text saves the task complete with all umlauts.

Issue 2: Using an uploaded image in a new task doesn't save the task sometimes properly. The Image itself gets destroyed and leaves always the same broken html closing tag instead as text. Example: Local file half_life_3_13463.png, Upload fine, Preview fine, Selectable as files/standard/9/half_life_3_13463.png in task editor, preview in task editor fine Saved Result: html> Database Entry: <img src="managefile.php?action=downloadfile" alt="html&gt;" /> Editing the existing task and re-inserting the existing file-link saves the task with the correct image. Reproducibility: Upload an image, insert the image by choosing "Insert / Edit Image" in the editor and try to change the image size and save.

Minor Issue 3: The feature to see online users as admin got removed in v3.x ?

Minor Issue 4: Feature to directly create new tasks within the project calendar got removed as well ?

Minor Issue 5: Assigning task to author, does not send out email notification to author.

Minor Issue 6: Stay logged in Session timeout value seems too short

Minor Issue 7: Drag&Drop of already uploaded files to created subfolders not working as intended. Files disappear from source, but never appear on target folder and re-appear on source again when switching back or reloading page

Thanks if you can look at Issues 1 and 2 in detail and attempt to fix it withing the next versions, because it is a bit annoying to re-write the same task, especially if it is more complex than the example above and contains images for visualization .. :-)

Trigonometry commented 7 years ago

As far as Issue 1 goes I tried to identify at which point exactly the problem starts. Looking at the Tamper data when you create a task containing umlauts for the first time you will notice the following error in $_POST variables:

[POST-Parameter] {Name} [] {} [title] {Test} [text] {Das ist ein Test f} [uuml;r mich.] {} [start] {07.02.2017} [end] {07.02.2017} [assigned[]] {1} [tasklist] {11}

The conversation of special-characters to their html entities equivalent causes the number of post fields to extend as "&" is used as a delimiter and converting ü to &#uuml; or > to &#lt; causes unexpected behaviour as for this example the post field for [text] should contain {Das+ist+ein+Test+f%C3%BCr+mich.} instead of getting splitted at the first occasion of an &.

Digging deeper and excluding the HTMLpurifier as cause brought me to the conclusion that something within the tinyMCE plugin was not setup properly during the first initialization (because editing existing tasks works like a charm with umlauts). After negative testing with the latest version of tinyMCE and reading the docs on their page the solution for the malformed text was simply to add entity_encoding: "raw", into the initialization block.

/templates/standard/header.tpl

        function initTinyMce() {
            tinyMCE.init({
                mode: "textareas",
                theme: "advanced",
                ...
                entity_encoding: "raw",
                external_image_list_url: 'manageajax.php?action=jsonfiles&id={/literal}{$project.ID}{literal}',
                setup: function (editor) {
                    editor.onChange.add(function () {
                        tinyMCE.triggerSave();
                    });
                }
            });
        }
        window.addEventListener("load",initTinyMce);
philippK-de commented 7 years ago

thank you for your thorrough bug report :) this is fixed in https://github.com/philippK-de/Collabtive/releases/tag/3.0.2