Skip to content

Commit

Permalink
fix(ui): License text editor
Browse files Browse the repository at this point in the history
Since the license text is read from the "title" of the element, which is
already HTML encoded in PHP, the textarea value needs to be decoded
first.
  • Loading branch information
GMishx committed May 25, 2021
1 parent 84a1897 commit c985342
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/www/ui/scripts/change-license-common.js
Expand Up @@ -240,6 +240,14 @@ function removeMainLicense(uploadId,licenseId) {
}
}

function htmlDecode(value) {
if (value) {
return $('<div/>').html(value).text();
} else {
return '';
}
}

function openTextModel(uploadTreeId, licenseId, what, type) {
var refTextId = "#referenceText"

Expand All @@ -256,7 +264,7 @@ function openTextModel(uploadTreeId, licenseId, what, type) {
let clearingsForSingleFile = $("#clearingsForSingleFile"+licenseId+what).attr("title");
idLicUploadTree = uploadTreeId+','+licenseId;
whatCol = what;
$(refTextId).val(clearingsForSingleFile);
$(refTextId).val(htmlDecode(clearingsForSingleFile));
if (what == 4 || what == "comment") {
createDropDown($("#textModal > form > div"), $("#referenceText"));
} else {
Expand All @@ -265,7 +273,7 @@ function openTextModel(uploadTreeId, licenseId, what, type) {
}
textModal.dialog('open');
} else {
$(refTextId).val($("#"+licenseId+what+type).attr('title'));
$(refTextId).val(htmlDecode($("#"+licenseId+what+type).attr('title')));
whatCol = what;
whatLicId = licenseId;
if (what == 4 || what == "comment") {
Expand Down

0 comments on commit c985342

Please sign in to comment.