diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php
index 28c3c975a51..4fad0d5a999 100644
--- a/htdocs/core/class/html.form.class.php
+++ b/htdocs/core/class/html.form.class.php
@@ -5055,8 +5055,8 @@ class Form
$autoOpen = false;
$dialogconfirm .= '-'.$button;
}
- $pageyes = $page.(preg_match('/\?/', $page) ? '&' : '?').'action='.$action.'&confirm=yes';
- $pageno = ($useajax == 2 ? $page.(preg_match('/\?/', $page) ? '&' : '?').'confirm=no' : '');
+ $pageyes = $page.(preg_match('/\?/', $page) ? '&' : '?').'action='.urlencode($action).'&confirm=yes';
+ $pageno = ($useajax == 2 ? $page.(preg_match('/\?/', $page) ? '&' : '?').'action='.urlencode($action).'&confirm=no' : '');
// Add input fields into list of fields to read during submit (inputok and inputko)
if (is_array($formquestion)) {