Backport Security Patches for Samples

This commit is contained in:
oleibman
2024-12-25 19:40:39 -08:00
parent 22c65debbb
commit b8fac55aa5
6 changed files with 24 additions and 14 deletions
+6 -3
View File
@@ -85,6 +85,8 @@ if (isset($_POST['submit'])) {
$helper->log('The Sample Number Value must be numeric');
} elseif (!is_numeric($_POST['decimals']) || str_contains((string) $_POST['decimals'], '.') || (int) $_POST['decimals'] < 0) {
$helper->log('The Decimal Places value must be positive integer');
} elseif (!in_array($_POST['currency'], array_keys($currencies), true)) {
$helper->log('Unrecognized currency symbol');
} else {
try {
$wizard = new Wizard\Currency($_POST['currency'], (int) $_POST['decimals'], isset($_POST['thousands']), (bool) $_POST['position'], (bool) $_POST['spacing']);
@@ -93,13 +95,14 @@ if (isset($_POST['submit'])) {
$helper->log('<hr /><b>Code:</b><br />');
$helper->log('use PhpOffice\PhpSpreadsheet\Style\NumberFormat\Wizard;');
$helper->log(
"\$mask = Wizard\\Currency('{$_POST['currency']}', {$_POST['decimals']}, Wizard\\Number::"
"\$wizard = new Wizard\\Currency('{$_POST['currency']}', {$_POST['decimals']}, Wizard\\Number::"
. (isset($_POST['thousands']) ? 'WITH_THOUSANDS_SEPARATOR' : 'WITHOUT_THOUSANDS_SEPARATOR')
. ', Wizard\Currency::' . (((bool) $_POST['position']) ? 'LEADING_SYMBOL' : 'TRAILING_SYMBOL')
. ', Wizard\Currency::' . (((bool) $_POST['spacing']) ? 'SYMBOL_WITH_SPACING' : 'SYMBOL_WITHOUT_SPACING')
. ');<br />'
. ');'
);
$helper->log('echo (string) $mask;');
$helper->log('$mask = $wizard->format();');
$helper->log('<br />echo (string) $mask;');
$helper->log('<hr /><b>Mask:</b><br />');
$helper->log($mask . '<br />');
$helper->log('<br /><b>Example:</b><br />');