Skip to content

Commit d896456

Browse files
committed
fix: added missing conversion to HTML entities
1 parent 00c0409 commit d896456

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

Diff for: phpmyfaq/admin/assets/js/tags.js

+5-1
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,10 @@ document.addEventListener('DOMContentLoaded', () => {
3636
const tag = input.val();
3737
const csrf = $('input[name=csrf]').val();
3838

39+
const escape = (unsafe) => {
40+
return unsafe.replaceAll('&', '&amp;').replaceAll('<', '&lt;').replaceAll('>', '&gt;').replaceAll('"', '&quot;').replaceAll("'", '&#039;');
41+
}
42+
3943
$.ajax({
4044
url: 'index.php?action=ajax&ajax=tags&ajaxaction=update',
4145
type: 'POST',
@@ -47,7 +51,7 @@ document.addEventListener('DOMContentLoaded', () => {
4751
);
4852
},
4953
success: function (message) {
50-
input.replaceWith('<span data-tag-id="' + id + '">' + input.val().replace(/\//g, '&#x2F;') + '</span>');
54+
input.replaceWith('<span data-tag-id="' + id + '">' + escape(input.val().replace(/\//g, '&#x2F;')) + '</span>');
5155
$('span[data-tag-id="' + id + '"]');
5256
$('#pmf-admin-saving-data-indicator').html(message);
5357
},

Diff for: phpmyfaq/admin/tags.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@
5555

5656
$tagData = $tags->getAllTags();
5757

58-
if (count($tagData)) {
58+
if (count($tagData) === 0) {
5959
printf('<p class="alert alert-warning" role="alert">%s</p>', $PMF_LANG['ad_news_nodata']);
6060
}
6161

@@ -64,7 +64,7 @@
6464

6565
foreach ($tagData as $key => $tag) {
6666
echo '<tr>';
67-
echo '<td><span data-tag-id="' . $key . '">' . Strings::htmlspecialchars($tag) . '</span></td>';
67+
echo '<td><span data-tag-id="' . $key . '">' . Strings::htmlentities($tag) . '</span></td>';
6868
printf(
6969
'<td><a class="btn btn-primary btn-edit" data-btn-id="%d" title="%s">' .
7070
'<i aria-hidden="true" class="fa fa-edit"></i></a></td>',

0 commit comments

Comments
 (0)