diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index ca3d0587905950460b77f6e60aac2aee6eefd217..50e3ecfb33f3abe7e578d08ffe9cce407571b3b2 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -276,9 +276,11 @@ function GETPOST($paramname, $check='', $method=0, $filter=NULL, $options=NULL) if (empty($method) || $method == 3 || $method == 4) { $relativepathstring = $_SERVER["PHP_SELF"]; + // Clean $relativepathstring if (constant('DOL_URL_ROOT')) $relativepathstring = preg_replace('/^'.preg_quote(constant('DOL_URL_ROOT'),'/').'/', '', $relativepathstring); - $relativepathstring = preg_replace('/^custom\//', '', $relativepathstring); $relativepathstring = preg_replace('/^\//', '', $relativepathstring); + $relativepathstring = preg_replace('/^custom\//', '', $relativepathstring); + //var_dump($relativepathstring); // Code for search criteria persistence. // Retrieve values if restore_lastsearch_values is set and there is saved values diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index dc3467a185de5fe7cf8c719ae1d28a6c6047b371..78f5d9d4f1e1c2c892548c2de60ee3ce119c0e3e 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -651,14 +651,14 @@ if (! defined('NOLOGIN')) if (! empty($_GET['save_lastsearch_values'])) // Keep $_GET here { $relativepathstring = preg_replace('/\?.*$/','',$_SERVER["HTTP_REFERER"]); - if (constant('DOL_MAIN_URL_ROOT')) $relativepathstring = preg_replace('/^'.preg_quote(constant('DOL_MAIN_URL_ROOT'),'/').'/', '', $relativepathstring); - $relativepathstring = preg_replace('/^custom\//', '', $relativepathstring); + $relativepathstring = preg_replace('/^https?:\/\/[^\/]*/','',$relativepathstring); // Get full path except host server + // Clean $relativepathstring + if (constant('DOL_URL_ROOT')) $relativepathstring = preg_replace('/^'.preg_quote(constant('DOL_URL_ROOT'),'/').'/', '', $relativepathstring); $relativepathstring = preg_replace('/^\//', '', $relativepathstring); - if (preg_match('/^https?:/', $relativepathstring)) - { - dol_syslog('Failted to save the search criteria. Calculation of relative page fails (check parameter $dolibarr_main_url_root in conf file match the URL you use in your browser).', LOG_WARNING); - } - elseif (! empty($_SESSION['lastsearch_values_tmp_'.$relativepathstring])) + $relativepathstring = preg_replace('/^custom\//', '', $relativepathstring); + //var_dump($relativepathstring); + + if (! empty($_SESSION['lastsearch_values_tmp_'.$relativepathstring])) { $_SESSION['lastsearch_values_'.$relativepathstring]=$_SESSION['lastsearch_values_tmp_'.$relativepathstring]; unset($_SESSION['lastsearch_values_tmp_'.$relativepathstring]);