Skip to content

Commit cc6abc7

Browse files
3.0.10
Fix for #3779, #3775 Fix for improper handling of input in admin setting pages
1 parent cb8ea5c commit cc6abc7

File tree

7 files changed

+44
-41
lines changed

7 files changed

+44
-41
lines changed

includes/js/functions.js

+25-4
Original file line numberDiff line numberDiff line change
@@ -395,10 +395,10 @@ function simplePurifier(
395395
bHtml = false,
396396
bSvg = false,
397397
bSvgFilters = false
398-
)
398+
)
399399
{
400400
return DOMPurify.sanitize(
401-
text
401+
sanitizeDom(text)
402402
.replaceAll('&lt;', '<')
403403
.replaceAll('&#x3C;', '<')
404404
.replaceAll('&#60;', '<')
@@ -515,6 +515,7 @@ function fieldDomPurifierWithWarning(
515515
bHtml = false,
516516
bSvg = false,
517517
bSvgFilters = false,
518+
bSetting = false,
518519
)
519520
{
520521
if (field === undefined || field === '') {
@@ -523,10 +524,22 @@ function fieldDomPurifierWithWarning(
523524
if ($(field).val() === '') {
524525
return '';
525526
}
526-
let string = '';
527+
let string = '',
528+
currentString = $(field).val();
529+
530+
// if bSetting is true, we use the setting value
531+
// remove any closing ', string that could corrupt the setting
532+
if (bSetting === true) {
533+
currentString = currentString.replace(/',/g, '');
534+
}
527535

528536
// Purify string
529-
string = simplePurifier($(field).val(), bHtml, bSvg, bSvgFilters);
537+
string = simplePurifier(
538+
sanitizeDom(currentString),
539+
bHtml,
540+
bSvg,
541+
bSvgFilters
542+
);
530543

531544
// Clear field if string is empty and warn user
532545
if (string === '') {
@@ -543,4 +556,12 @@ function fieldDomPurifierWithWarning(
543556
}
544557

545558
return string;
559+
}
560+
561+
const sanitizeDom = (str) => {
562+
const div = document.createElement('div');
563+
div.textContent = str;
564+
newString = div.innerHTML;
565+
div.remove();
566+
return newString;
546567
}

includes/libraries/anti-xss-master/src/voku/helper/AntiXSS.php

+1
Original file line numberDiff line numberDiff line change
@@ -455,6 +455,7 @@ public function __construct()
455455
{
456456
$this->_initNeverAllowedStr();
457457
$this->_initNeverAllowedRegex();
458+
UTF8::checkForSupport();
458459
}
459460

460461
/**

pages/2fa.js.php

+6-25
Original file line numberDiff line numberDiff line change
@@ -55,34 +55,15 @@
5555
<script type='text/javascript'>
5656
//<![CDATA[
5757

58-
console.log('2FA loaded')
59-
60-
$(document).on('click', '.generate-key', function() {
61-
var size = $(this).data('length'),
62-
target = $(this).closest('.input-group').find('input').attr('id');
63-
64-
$.post(
65-
'sources/main.queries.php', {
66-
type: 'generate_new_key',
67-
type_category: 'action_key',
68-
size: size
69-
},
70-
function(data) {
71-
$('#' + target).val(data[0].key);
72-
},
73-
'json'
74-
);
75-
})
76-
77-
7858
$(document).on('click', '#button-duo-config-check', function() {
79-
var data = "{\"ikey\":\"" + sanitizeString($("#duo_ikey").val()) + "\", \"skey\":\"" + sanitizeString($("#duo_skey").val()) + "\", \"host\":\"" + sanitizeString($("#duo_host").val()) + "\"}";
59+
toastr
60+
.info('<?php echo langHdl('loading_item'); ?> ... <i class="fas fa-circle-notch fa-spin fa-2x"></i>');
8061

8162
// Prepare data
8263
var data = {
83-
'duo_ikey': $('#duo_ikey').val(),
84-
'duo_skey': $('#duo_skey').val(),
85-
'duo_host': $('#duo_host').val()
64+
'duo_ikey': sanitizeString($('#duo_ikey').val()),
65+
'duo_skey': sanitizeString($('#duo_skey').val()),
66+
'duo_host': sanitizeString($('#duo_host').val())
8667
}
8768
console.log(data);
8869

@@ -110,7 +91,7 @@ function(data) {
11091
} else {
11192
// Inform user
11293
toastr.remove();
113-
toastr.info(
94+
toastr.success(
11495
'<?php echo langHdl('duo-config-check-success'); ?>',
11596
'', {
11697
timeOut: 5000

pages/2fa.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@
157157
</small>
158158
</div>
159159
<div class="col-3">
160-
<input type="text" class="form-control form-control-sm" id="ga_website_name" value="<?php echo isset($SETTINGS['ga_website_name']) === true ? $SETTINGS['ga_website_name'] : ''; ?>">
160+
<input type="text" class="form-control form-control-sm purify" data-field="label" id="ga_website_name" value="<?php echo isset($SETTINGS['ga_website_name']) === true ? $SETTINGS['ga_website_name'] : ''; ?>">
161161
</div>
162162
</div>
163163

@@ -205,23 +205,23 @@
205205
<?php echo langHdl('admin_duo_ikey'); ?>
206206
</div>
207207
<div class="col-7">
208-
<input type="text" class="form-control form-control-sm" id="duo_ikey" value="<?php echo isset($SETTINGS['duo_ikey']) === true ? $SETTINGS['duo_ikey'] : ''; ?>">
208+
<input type="text" class="form-control form-control-sm purify" data-field="label" id="duo_ikey" value="<?php echo isset($SETTINGS['duo_ikey']) === true ? $SETTINGS['duo_ikey'] : ''; ?>">
209209
</div>
210210
</div>
211211
<div class="row mb-2">
212212
<div class="col-5">
213213
<?php echo langHdl('admin_duo_skey'); ?>
214214
</div>
215215
<div class="col-7">
216-
<input type="text" class="form-control form-control-sm" id="duo_skey" value="<?php echo isset($SETTINGS['duo_skey']) === true ? $SETTINGS['duo_skey'] : ''; ?>">
216+
<input type="text" class="form-control form-control-sm purify" data-field="label" id="duo_skey" value="<?php echo isset($SETTINGS['duo_skey']) === true ? $SETTINGS['duo_skey'] : ''; ?>">
217217
</div>
218218
</div>
219219
<div class="row mb-2">
220220
<div class="col-5">
221221
<?php echo langHdl('admin_duo_host'); ?>
222222
</div>
223223
<div class="col-7">
224-
<input type="text" class="form-control form-control-sm" id="duo_host" value="<?php echo isset($SETTINGS['duo_host']) === true ? $SETTINGS['duo_host'] : ''; ?>">
224+
<input type="text" class="form-control form-control-sm purify" data-field="label" id="duo_host" value="<?php echo isset($SETTINGS['duo_host']) === true ? $SETTINGS['duo_host'] : ''; ?>">
225225
</div>
226226
</div>
227227

pages/admin.js.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ function(data) {
135135
}
136136

137137
// Sanitize value
138-
value = fieldDomPurifierWithWarning('#' + field);
138+
value = fieldDomPurifierWithWarning('#' + field, false, false, false, true);
139139
if (value === false) {
140140
return false;
141141
}

pages/users.js.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -898,7 +898,7 @@ function(data) {
898898

899899
// Mandatory?
900900
var validated = true,
901-
validEmailRegex = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/;
901+
validEmailRegex = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,15})+$/;
902902
$('.required').each(function(i, obj) {
903903
if ($(this).val() === '' && $(this).hasClass('select2') === false) {
904904
$(this).addClass('is-invalid');

sources/logs.datatables.php

+6-6
Original file line numberDiff line numberDiff line change
@@ -838,7 +838,7 @@
838838
}
839839
} elseif (isset($_GET['action']) && $_GET['action'] === 'tasks_in_progress') {
840840
//Columns name
841-
$aColumns = ['increment_id', 'created_at', 'updated_at', 'process_type', 'is_in_progress'];
841+
$aColumns = ['p.increment_id', 'p.created_at', 'p.updated_at', 'p.process_type', 'p.is_in_progress'];
842842
//Ordering
843843
if (isset($_GET['order'][0]['dir']) === true
844844
&& in_array($_GET['order'][0]['dir'], $aSortTypes) === true
@@ -854,7 +854,7 @@
854854
$aColumns[0].' DESC';
855855
}
856856

857-
$sWhere = ' WHERE ((finished_at = "")';
857+
$sWhere = ' WHERE ((p.finished_at = "")';
858858
if (isset($_GET['search']['value']) === true && $_GET['search']['value'] !== '') {
859859
$sWhere .= ' AND (';
860860
for ($i = 0; $i < count($aColumns); ++$i) {
@@ -865,13 +865,13 @@
865865
$sWhere .= ') ';
866866
DB::debugmode(false);
867867
$iTotal = DB::queryFirstField(
868-
'SELECT COUNT(increment_id)
868+
'SELECT COUNT(p.increment_id)
869869
FROM '.prefixTable('processes').' AS p
870870
LEFT JOIN '.prefixTable('users').' AS u ON u.id = json_extract(p.arguments, "$[0]")'.
871871
$sWhere
872872
);
873873
$rows = DB::query(
874-
'SELECT *
874+
'SELECT p.*
875875
FROM '.prefixTable('processes').' AS p
876876
LEFT JOIN '.prefixTable('users').' AS u ON u.id = json_extract(p.arguments, "$[0]")'.
877877
$sWhere.
@@ -951,14 +951,14 @@
951951

952952
DB::debugmode(false);
953953
$iTotal = DB::queryFirstField(
954-
'SELECT COUNT(increment_id)
954+
'SELECT COUNT(p.increment_id)
955955
FROM '.prefixTable('processes').' AS p
956956
LEFT JOIN '.prefixTable('users').' AS u ON u.id = json_extract(p.arguments, "$[0]")'.
957957
$sWhere
958958
);
959959

960960
$rows = DB::query(
961-
'SELECT *
961+
'SELECT p.*
962962
FROM '.prefixTable('processes').' AS p
963963
LEFT JOIN '.prefixTable('users').' AS u ON u.id = json_extract(p.arguments, "$[0]")'.
964964
$sWhere.

0 commit comments

Comments
 (0)