Bugfix tax names (#4677)

bugfix(items, validation): reject unsafe tax names and fix payments temp table collision

- Add unicode_alpha_numeric_punct rule (OSPOSRules) to allow accented/CJK
  chars in text fields while blocking HTML-unsafe chars (<, >) as
  defense-in-depth against injection
- Items controller: extract validateItemFields/validateBulkUpdateFields,
  validate tax_names on save and bulk update using new rule; add shared
  validateFields helper in Secure_Controller to DRY up validation +
  JSON error response
- Escape tax_group output in sales/quote.php and receipt_email.php views
  to harden output encoding at render time
- Rename sales_payments_temp -> sales_report_payments_temp (Summary_report)
  and -> sales_search_payments_temp (Sale model) to avoid name collision
  between concurrently-created temp tables
- AGENTS.md: document alignment rule for => columns when inserting new
  language keys

Tests:
- Add ItemsControllerTest covering postSave/bulkupdate tax_names validation
- Reject <, > in tax_names on /items/save and /items/bulkupdate
- Verify unicode and apostrophe-containing tax names are accepted
- Cover CSV import helpers: header generation (basic, multiple locations,
  attributes), stock-location/attribute header builders, get_csv_file
  parsing (plain, BOM-prefixed, multi-row)
- Validate required-header detection for import templates
- Remove outdated tax name test from SalesControllerTest
- Simplify Database class references in SalesControllerTest

i18n:
- Add tax_name_invalid translation to Items.php for 20+ locales, inserted
  alphabetically after tax_category in each file
- Normalize quote style in ar-EG/Items.php to single quotes
- Add ka/Items.php Georgian locale scaffold

Signed-off-by: objecttothis <17935339+objecttothis@users.noreply.github.com>
This commit is contained in:
objecttothis authored and GitHub committed 2026-09-01 10:59:29 +04:00
1 parent 905a447e55
commit 6db3dde491
58 files changed
+5777 -5334

No files matched your search

+19
View File
@@ -78,6 +78,25 @@ class Secure_Controller extends BaseController
return $field != null && in_array($field, array_keys(array_merge(...$headers))) ? $field : $default;
}
/**
* Validates the given rules and, on failure, returns a JSON error response.
*
* @param array $rules
* @param array $messages
* @param mixed $id
* @return ResponseInterface|null
*/
protected function validateFields(array $rules, array $messages, $id = NEW_ENTRY): ?ResponseInterface
{
if (!$this->validate($rules, $messages)) {
$errors = $this->validator->getErrors();
return $this->response->setJSON(['success' => false, 'message' => reset($errors), 'id' => $id]);
}
return null;
}
/**
* AJAX function used to confirm whether values sent in the request are numeric
* @return ResponseInterface