From f96a4af9f3730126bd6301d8ef2ca04e6022fee3 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 13 Jul 2026 12:04:47 +0200 Subject: [PATCH] Doc --- AGENTS.md | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/AGENTS.md b/AGENTS.md index e2a9fbdfafb..070e899949b 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -65,8 +65,7 @@ Before writing any code, the agent **must**: - Use Dolibarr database functions exclusively — never use PDO or MySQLi directly - In pages: use global `$db` - In classes: use `$this->db` -- ✅ Always escape user inputs -- ✅ SQL forged by PHP must escape fields with `db->escape()`, `db->sanitize()`, or by casting values to `(int)` or `(float)` +- ✅ SQL forged by PHP must escaped fields with `db->escape()`, `db->sanitize()`, or by casting values to `(int)` or `(float)` - ✅ Always use `$db->query()` followed by `$db->fetch_object()` or `$db->fetch_array()` to retrieve results - ✅ SQL scripts for table and index creation must be placed in `htdocs/install/mysql/tables/` (see existing files for examples) - ❌ Never run SQL queries inside loops (avoid N+1 problem — use JOINs or batch queries instead) @@ -126,7 +125,7 @@ If possible: - Always validate user inputs (`GET`, `POST`) via `GETPOST()` with a type parameter - Prevent SQL injection (use `db->escape()` or cast into `(int)` or `(float)`) -- Prevent XSS injection (use `dolPrintHTML()`, `dolPrintHTMLForAttribute()`, ...) +- Prevent XSS injection by escaping HTML output (use `dolPrintHTML()`, `dolPrintHTMLForAttribute()`) - Always include Dolibarr CSRF tokens in POST forms: `` ---