mirror of
https://codeberg.org/PostERG/xamxam.git
synced 2026-05-07 03:29:19 +02:00
fix: duplicate warning not shown in admin, double-encoded in partage, no focus
- toast-fragment.php: 204 early-exit now also checks flash['warning']; previously the warning was consumed by consumeFlash() then silently dropped - partage/index.php: store warning as plain text; htmlspecialchars() applied once at render time — previously htmlspecialchars() was called inside the stored string then again at output, producing ' entities etc. - partage/index.php: flash-warning div gets id + tabindex=-1; inline JS scrolls it into view and focuses it on DOMContentLoaded - admin/footer.php: htmx:afterSettle listener focuses .toast--warning after HTMX injects the toast fragment into #toast-region
This commit is contained in:
@@ -13,7 +13,7 @@ AdminAuth::requireLogin();
|
||||
if (!isset($_POST['csrf_token'], $_SESSION['csrf_token'])
|
||||
|| !hash_equals($_SESSION['csrf_token'], $_POST['csrf_token'])) {
|
||||
error_log(sprintf(
|
||||
'CSRF token validation failed in formulaire.php — POST token: %s, SESSION token: %s',
|
||||
'CSRF token validation failed in formulaire.php - POST token: %s, SESSION token: %s',
|
||||
$_POST['csrf_token'] ?? '(missing)',
|
||||
$_SESSION['csrf_token'] ?? '(missing)'
|
||||
));
|
||||
@@ -49,10 +49,10 @@ try {
|
||||
|
||||
// Build a warning with a clickable link to the existing thesis.
|
||||
$existingUrl = htmlspecialchars('/admin/edit.php?id=' . $e->existingThesisId);
|
||||
$existingRef = htmlspecialchars($e->existingIdentifier . ' — ' . $e->existingTitle . ' (' . $e->existingYear . ')');
|
||||
$warningHtml = 'Doublon détecté : un TFE très similaire existe déjà. '
|
||||
. '<a href="' . $existingUrl . '" style="color:inherit;text-decoration:underline">' . $existingRef . '</a>'
|
||||
. ' Vérifiez avant de soumettre à nouveau.';
|
||||
$existingRef = htmlspecialchars($e->existingIdentifier . ' - ' . $e->existingTitle . ' (' . $e->existingYear . ')');
|
||||
$warningHtml = 'Doublon détecté : un TFE très similaire existe déjà.'
|
||||
. '<br><a href="' . $existingUrl . '">' . $existingRef . '</a>'
|
||||
. '<br>Vérifiez avant de soumettre à nouveau.';
|
||||
|
||||
App::flash('warning', $warningHtml);
|
||||
$_SESSION['form_data'] = $_POST;
|
||||
|
||||
@@ -13,7 +13,7 @@ AdminAuth::requireLogin();
|
||||
|
||||
$flash = App::consumeFlash();
|
||||
|
||||
if (!$flash['error'] && !$flash['success']) {
|
||||
if (!$flash['error'] && !$flash['success'] && !$flash['warning']) {
|
||||
http_response_code(204);
|
||||
exit;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user