Merge remote-tracking branch 'origin/support/2.7' into develop

# Conflicts:
#	application/transaction.class.inc.php
#	application/ui.extkeywidget.class.inc.php
#	composer.json
#	composer.lock
#	js/utils.js
#	lib/composer/InstalledVersions.php
#	lib/composer/installed.json
#	lib/composer/installed.php
#	lib/pear/archive_tar/Archive/Tar.php
#	lib/pear/archive_tar/package.xml
#	setup/wizardsteps.class.inc.php
#	sources/Controller/AjaxRenderController.php
This commit is contained in:
Pierre Goiffon
2021-10-18 14:44:34 +02:00
20 changed files with 468 additions and 350 deletions

View File

@@ -974,4 +974,70 @@ const CombodoJSConsole = {
Error: function(sMessage) {
this._Trace(sMessage, 'error');
}
}
}
/**
* Helper to Sanitize string
*
* Note: Same as in php (see \utils::Sanitize)
*
* @api
* @since 2.6.5 2.7.6 3.0.0 N°4367
*/
const CombodoSanitizer = {
ENUM_SANITIZATION_FILTER_INTEGER: 'integer',
ENUM_SANITIZATION_FILTER_STRING: 'string',
ENUM_SANITIZATION_FILTER_CONTEXT_PARAM: 'context_param',
ENUM_SANITIZATION_FILTER_PARAMETER: 'parameter',
ENUM_SANITIZATION_FILTER_FIELD_NAME: 'field_name',
ENUM_SANITIZATION_FILTER_TRANSACTION_ID: 'transaction_id',
ENUM_SANITIZATION_FILTER_ELEMENT_IDENTIFIER: 'element_identifier',
ENUM_SANITIZATION_FILTER_VARIABLE_NAME: 'variable_name',
/**
* @param {String} sValue The string to sanitize
* @param {String} sDefaultValue The string to return if sValue not match (used for some filters)
* @param {String} sSanitizationFilter one of the ENUM_SANITIZATION_FILTERs
*/
Sanitize: function (sValue, sDefaultValue, sSanitizationFilter) {
switch (sSanitizationFilter) {
case CombodoSanitizer.ENUM_SANITIZATION_FILTER_INTEGER:
return this._CleanString(sValue, sDefaultValue, /[^0-9-+]*/g);
case CombodoSanitizer.ENUM_SANITIZATION_FILTER_STRING:
return $("<div>").text(sValue).text();
case CombodoSanitizer.ENUM_SANITIZATION_FILTER_TRANSACTION_ID:
return this._ReplaceString(sValue, sDefaultValue, /^([\. A-Za-z0-9_=-]*)$/g, '');
case CombodoSanitizer.ENUM_SANITIZATION_FILTER_PARAMETER:
return this._ReplaceString(sValue, sDefaultValue, /^([ A-Za-z0-9_=-]*)$/g);
case CombodoSanitizer.ENUM_SANITIZATION_FILTER_FIELD_NAME:
return this._ReplaceString(sValue, sDefaultValue, /^[A-Za-z0-9_]+(->[A-Za-z0-9_]+)*$/g);
case CombodoSanitizer.ENUM_SANITIZATION_FILTER_CONTEXT_PARAM:
return this._ReplaceString(sValue, sDefaultValue, /^[ A-Za-z0-9_=%:+-]*$/g);
case CombodoSanitizer.ENUM_SANITIZATION_FILTER_ELEMENT_IDENTIFIER:
return this._CleanString(sValue, sDefaultValue, /[^a-zA-Z0-9_-]/g);
case CombodoSanitizer.ENUM_SANITIZATION_FILTER_VARIABLE_NAME:
return this._CleanString(sValue, sDefaultValue, /[^a-zA-Z0-9_]/g);
}
return sDefaultValue;
},
_CleanString: function (sValue, sDefaultValue, sRegExp) {
return sValue.replace(sRegExp, '');
},
_ReplaceString: function (sValue, sDefaultValue, sRegExp) {
if (sRegExp.test(sValue)) {
return sValue;
} else {
return sDefaultValue;
}
}
}