- fix error if script title was saved in settings in non-utf8 encoding

This commit is contained in:
Max Pozdeev 2022-04-15 18:39:45 +03:00
parent dd5e4f63ce
commit 4e083c6327
2 changed files with 10 additions and 1 deletions

View file

@ -29,7 +29,7 @@
$().ready(function(){
mytinytodo.init({
token: "<?php echo htmlspecialchars(access_token()); ?>" ,
title: <?php echo json_encode(get_unsafe_mttinfo('title'), JSON_UNESCAPED_UNICODE); ?> ,
title: <?php echo mtt_quoted_title() ?> ,
lang: <?php echo Lang::instance()->makeJS() ?>,
mttUrl: "<?php mttinfo('mtt_url'); ?>",
homeUrl: "<?php mttinfo('url'); ?>",

View file

@ -250,6 +250,15 @@ function reset_mttinfo($key)
unset( $_mttinfo[$key] );
}
function mtt_quoted_title()
{
$s = json_encode(get_unsafe_mttinfo('title'), JSON_UNESCAPED_UNICODE);
if ($s === false) {
return '""';
}
return $s;
}
function getRequestUri()
{
// Do not use HTTP_X_REWRITE_URL due to CVE-2018-14773