mirror of
https://codeberg.org/PostERG/xamxam.git
synced 2026-05-07 03:29:19 +02:00
fix(formulaire): remove htmlspecialchars from sanitize_string + delete dead $problematique
HTML-escaping at write time stores &, < etc. in the DB, corrupting full-text search, tag matching, exports, and any non-HTML consumer. PDO parameterised queries already prevent SQL injection; templates call htmlspecialchars() on output. sanitize_string() now does strip_tags(trim()) only — matching the pattern already used by edit.php which never had this bug. Also deleted the dead $problematique variable (read from POST[problématique] but never passed to any INSERT or used anywhere in the codebase).
This commit is contained in:
@@ -25,7 +25,9 @@ require_once __DIR__ . '/../../src/Database.php';
|
||||
|
||||
// Helper function to sanitize string input
|
||||
function sanitize_string($input) {
|
||||
return htmlspecialchars(strip_tags(trim($input)), ENT_QUOTES, 'UTF-8');
|
||||
// Trim and strip raw HTML tags only — htmlspecialchars belongs at render time, not storage time.
|
||||
// PDO parameterised queries handle SQL injection; the templates call htmlspecialchars() on output.
|
||||
return strip_tags(trim($input));
|
||||
}
|
||||
|
||||
// Helper function to validate required field
|
||||
@@ -81,7 +83,6 @@ try {
|
||||
$titre = validate_required(sanitize_string($_POST["titre"] ?? ''), "Titre du mémoire");
|
||||
$subtitle = sanitize_string($_POST["subtitle"] ?? '');
|
||||
$synopsis = validate_required(sanitize_string($_POST["synopsis"] ?? ''), "Synopsis");
|
||||
$problematique = sanitize_string($_POST["problématique"] ?? '');
|
||||
$durationInfo = sanitize_string($_POST["duration_info"] ?? '');
|
||||
|
||||
// Jury members
|
||||
|
||||
Reference in New Issue
Block a user