[BUGFIX] suggest wizards correctly encode long html results 05/44505/3
authorAndreas Allacher <andreas@allacher.com>
Tue, 3 Nov 2015 13:35:37 +0000 (14:35 +0100)
committerChristian Kuhn <lolli@schwarzbu.ch>
Wed, 4 Nov 2015 11:39:08 +0000 (12:39 +0100)
The suggest wizard has to ensure that long results
are correctly HTML encoded in the data attribute.
Otherwise various necessary data attributes
are missing and the result cannot be stored.

Change-Id: Icb5ef7ad979effc5681f21165df2356a0e08480a
Resolves: #69211
Releases: master
Reviewed-on: https://review.typo3.org/44505
Reviewed-by: Nicole Cordes <typo3@cordes.co>
Tested-by: Nicole Cordes <typo3@cordes.co>
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
Tested-by: Christian Kuhn <lolli@schwarzbu.ch>
typo3/sysext/backend/Resources/Public/JavaScript/FormEngineSuggest.js

index 3b3d007..9858274 100644 (file)
@@ -59,9 +59,14 @@ define(['jquery', 'jquery/autocomplete'], function ($) {
                        },
                        // Rendering of each item
                        formatResult: function(suggestion, value) {
-                               return '<a class="autocomplete-suggestion-link" href="#" data-label="' + suggestion.data.label + '" data-table="' + suggestion.data.table + '" data-uid="' + suggestion.data.uid + '">' +
-                                               suggestion.data.sprite + suggestion.data.text +
-                                       '</a>';
+                               return $('<div>').append(
+                                                       $('<a class="autocomplete-suggestion-link" href="#">' +
+                                                               suggestion.data.sprite + suggestion.data.text +
+                                                       '</a></div>').attr({
+                                                               'data-label': suggestion.data.label,
+                                                               'data-table': suggestion.data.table,
+                                                               'data-uid': suggestion.data.uid
+                                                       })).html();
                        },
                        onSearchComplete: function() {
                                $containerElement.addClass('open');
@@ -87,7 +92,10 @@ define(['jquery', 'jquery/autocomplete'], function ($) {
                        }
 
                        var formEl = $searchField.data('fieldname');
-                       setFormValueFromBrowseWin(formEl, insertData, $(this).data('label'), $(this).data('label'));
+                       var labelEl = $('<div>').html($(this).data('label'));
+                       var label = labelEl.text();
+                       var title = labelEl.find('span').attr('title') || label;
+                       setFormValueFromBrowseWin(formEl, insertData, label, title);
                        TBE_EDITOR.fieldChanged(table, uid, field, formEl);
                });
        };