Skip to content

Commit

Permalink
fix use of removed escapeHTML in settings.js
Browse files Browse the repository at this point in the history
- solves non-working "additional settings" sections (at least)

Signed-off-by: Arthur Schiwon <[email protected]>
  • Loading branch information
blizzz committed Sep 7, 2020
1 parent 47e7257 commit 0f02760
Showing 1 changed file with 43 additions and 34 deletions.
77 changes: 43 additions & 34 deletions apps/settings/js/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,39 +3,48 @@
* This file is licensed under the Affero General Public License version 3 or later.
* See the COPYING-README file.
*/
OC.Settings = OC.Settings || {};
OC.Settings = OC.Settings || {}
OC.Settings = _.extend(OC.Settings, {

_cachedGroups: null,

escapeHTML(text) {
return text.toString()
.split('&').join('&amp;')
.split('<').join('&lt;')
.split('>').join('&gt;')
.split('"').join('&quot;')
.split('\'').join('&#039;')
},

/**
* Setup selection box for group selection.
*
* Values need to be separated by a pipe "|" character.
* (mostly because a comma is more likely to be used
* for groups)
*
* @param $elements jQuery element (hidden input) to setup select2 on
* @param {Object} $elements jQuery element (hidden input) to setup select2 on
* @param {Array} [extraOptions] extra options hash to pass to select2
* @param {Array} [options] extra options
* @param {Array} [options.excludeAdmins=false] flag whether to exclude admin groups
*/
setupGroupsSelect: function($elements, extraOptions, options) {
var self = this;
options = options || {};
setupGroupsSelect($elements, extraOptions, options) {
var self = this
options = options || {}
if ($elements.length > 0) {
// Let's load the data and THEN init our select
$.ajax({
url: OC.linkToOCS('cloud/groups', 2) + 'details',
dataType: 'json',
success: function(data) {
var results = [];
success(data) {
var results = []

if (data.ocs.data.groups && data.ocs.data.groups.length > 0) {

data.ocs.data.groups.forEach(function(group) {
if (!options.excludeAdmins || group.id !== 'admin') {
results.push({ id: group.id, displayname: group.displayname });
results.push({ id: group.id, displayname: group.displayname })
}
})

Expand All @@ -47,10 +56,10 @@ OC.Settings = _.extend(OC.Settings, {
multiple: true,
toggleSelect: true,
separator: '|',
data: { results: results, text: 'displayname' },
initSelection: function(element, callback) {
var groups = $(element).val();
var selection;
data: { results, text: 'displayname' },
initSelection(element, callback) {
var groups = $(element).val()
var selection
if (groups && results.length > 0) {
selection = _.map(_.filter((groups || []).split('|').sort(), function(groupId) {
return results.find(function(group) {
Expand All @@ -61,40 +70,40 @@ OC.Settings = _.extend(OC.Settings, {
id: groupId,
displayname: results.find(function(group) {
return group.id === groupId
}).displayname
}).displayname,
}
})
} else if (groups) {
selection = _.map((groups || []).split('|').sort(), function(groupId) {
return {
id: groupId,
displayname: groupId
};
});
displayname: groupId,
}
})
}
callback(selection);
callback(selection)
},
formatResult: function(element) {
return escapeHTML(element.displayname);
formatResult(element) {
return self.escapeHTML(element.displayname)
},
formatSelection: function(element) {
return escapeHTML(element.displayname);
formatSelection(element) {
return self.escapeHTML(element.displayname)
},
escapeMarkup: function(m) {
escapeMarkup(m) {
// prevent double markup escape
return m;
}
}, extraOptions || {}));
return m
},
}, extraOptions || {}))
} else {
OC.Notification.show(t('settings', 'Group list is empty'), { type: 'error' });
console.log(data);
OC.Notification.show(t('settings', 'Group list is empty'), { type: 'error' })
console.error(data)
}
},
error: function(data) {
OC.Notification.show(t('settings', 'Unable to retrieve the group list'), { type: 'error' });
console.log(data);
}
});
error(data) {
OC.Notification.show(t('settings', 'Unable to retrieve the group list'), { type: 'error' })
console.error(data)
},
})
}
}
});
},
})

0 comments on commit 0f02760

Please sign in to comment.