From 5248a9bc33b3c39e4375aaebcba2f601f422e50a Mon Sep 17 00:00:00 2001 From: Max Pozdeev Date: Mon, 6 Sep 2021 22:52:08 +0300 Subject: [PATCH] * fix incorrect title in browser history in some cases --- src/includes/common.php | 5 +++++ src/index.php | 2 +- src/init.php | 4 ++-- src/settings.php | 8 ++++---- 4 files changed, 12 insertions(+), 7 deletions(-) diff --git a/src/includes/common.php b/src/includes/common.php index 3e7fbe6..3656f38 100644 --- a/src/includes/common.php +++ b/src/includes/common.php @@ -100,6 +100,11 @@ function url_dir($url, $onlyPath = 1) return '/'; } +function removeNewLines($s) +{ + return str_replace( ["\r","\n"], '', $s ); +} + /* found in comments on http://www.php.net/manual/en/function.uniqid.php#94959 */ function generateUUID() { diff --git a/src/index.php b/src/index.php index 6b0a3c7..3e3ecde 100644 --- a/src/index.php +++ b/src/index.php @@ -51,7 +51,7 @@ function redirectWithHashRoute(array $q, array $hash) function js_options() { $a = array( - "title" => get_mttinfo('title', false), + "title" => get_unsafe_mttinfo('title'), "lang" => Lang::instance()->jsStrings(), "mttUrl" => get_mttinfo('mtt_url'), "homeUrl" => get_mttinfo('url'), diff --git a/src/init.php b/src/init.php index 31c2f09..dc7a6c4 100644 --- a/src/init.php +++ b/src/init.php @@ -154,9 +154,9 @@ function __($s) return Lang::instance()->get($s); } -function mttinfo($v, $escape = true) +function mttinfo($v) { - echo $escape ? get_mttinfo($v) : get_unsafe_mttinfo($v); + echo get_mttinfo($v); } /* diff --git a/src/settings.php b/src/settings.php index 7ac72ac..128819d 100644 --- a/src/settings.php +++ b/src/settings.php @@ -43,10 +43,10 @@ if(isset($_POST['save'])) Config::set('autotag', (int)_post('autotag')); Config::set('firstdayofweek', (int)_post('firstdayofweek')); Config::set('clock', (int)_post('clock')); - Config::set('dateformat', _post('dateformat')); - Config::set('dateformat2', _post('dateformat2')); - Config::set('dateformatshort', _post('dateformatshort')); - Config::set('title', trim(_post('title'))); + Config::set('dateformat', removeNewLines(_post('dateformat')) ); + Config::set('dateformat2', removeNewLines(_post('dateformat2')) ); + Config::set('dateformatshort', removeNewLines(_post('dateformatshort')) ); + Config::set('title', removeNewLines(trim(_post('title'))) ); Config::set('showdate', (int)_post('showdate')); Config::save(); $t['saved'] = 1;