Merge pull request #22042 from FHenry/14_fix_22040

FIX: bad bookmark save
This commit is contained in:
Laurent Destailleur 2022-09-02 10:59:14 +02:00 committed by GitHub
commit cf379bdbec
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -36,11 +36,18 @@ function printDropdownBookmarksList()
$langs->load("bookmarks"); $langs->load("bookmarks");
$authorized_var=array('limit','optioncss','contextpage');
$url = $_SERVER["PHP_SELF"]; $url = $_SERVER["PHP_SELF"];
$url_param=array();
if (!empty($_SERVER["QUERY_STRING"])) { if (!empty($_SERVER["QUERY_STRING"])) {
$url .= (dol_escape_htmltag($_SERVER["QUERY_STRING"]) ? '?'.dol_escape_htmltag($_SERVER["QUERY_STRING"]) : ''); if (is_array($_GET)) {
} else { foreach ($_GET as $key => $val) {
if ($val != '') {
$url_param[$key]=http_build_query(array(dol_escape_htmltag($key) => dol_escape_htmltag($val)));
}
}
}
}
global $sortfield, $sortorder; global $sortfield, $sortorder;
$tmpurl = ''; $tmpurl = '';
// No urlencode, all param $url will be urlencoded later // No urlencode, all param $url will be urlencoded later
@ -52,12 +59,16 @@ function printDropdownBookmarksList()
} }
if (is_array($_POST)) { if (is_array($_POST)) {
foreach ($_POST as $key => $val) { foreach ($_POST as $key => $val) {
if (preg_match('/^search_/', $key) && $val != '') { if ((preg_match('/^search_/', $key) || in_array($key, $authorized_var))
$tmpurl .= ($tmpurl ? '&' : '').http_build_query(array($key => $val)); && $val != ''
&& !array_key_exists($key, $url_param)) {
$url_param[$key]=http_build_query(array(dol_escape_htmltag($key) => dol_escape_htmltag($val)));
} }
} }
} }
$url .= ($tmpurl ? '?'.$tmpurl : ''); $url .= ($tmpurl ? '?'.$tmpurl : '');
if (!empty($url_param)) {
$url .= '&'.implode('&', $url_param);
} }
$searchForm = '<!-- form with POST method by default, will be replaced with GET for external link by js -->'."\n"; $searchForm = '<!-- form with POST method by default, will be replaced with GET for external link by js -->'."\n";