From 7a96dd7549eab6f259355d90c026d429ac2b411d Mon Sep 17 00:00:00 2001 From: Spirit Date: Sun, 2 Aug 2020 22:20:56 +0800 Subject: [PATCH 1/3] fix: fix code block data-rel fix #235 --- js/sakura-app.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/js/sakura-app.js b/js/sakura-app.js index 9bbd6ed..1d041c1 100644 --- a/js/sakura-app.js +++ b/js/sakura-app.js @@ -146,7 +146,7 @@ function code_highlight_style() { } var ele_name = $('pre:eq(' + i + ')')[0].children[0].className; var lang = ele_name.substr(0, ele_name.indexOf(" ")).replace('language-', ''); - if (lang.toLowerCase() == "hljs") var lang = "text"; + if (lang.toLowerCase() == "hljs") var lang = $('pre:eq(' + i + ') code').attr("class").replace('hljs', '')?$('pre:eq(' + i + ') code').attr("class").replace('hljs', ''):"text"; $('pre:eq(' + i + ')').addClass('highlight-wrap'); for (var t in attributes) { $('pre:eq(' + i + ')').attr(t, attributes[t]); From e15bbeb8966d27a610d86716c188bf8c6b43c230 Mon Sep 17 00:00:00 2001 From: Spirit Date: Sun, 2 Aug 2020 22:35:08 +0800 Subject: [PATCH 2/3] fix: fix webp image covver fix #234 --- inc/classes/Images.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/inc/classes/Images.php b/inc/classes/Images.php index f0675f4..6ba6ccd 100644 --- a/inc/classes/Images.php +++ b/inc/classes/Images.php @@ -154,7 +154,7 @@ class Images $img_array = json_decode($sakura_image_array, true); $img = array_rand($img_array); $img_domain = akina_option('cover_cdn') ? akina_option('cover_cdn') : get_template_directory_uri(); - if (strpos($_SERVER['HTTP_ACCEPT'], 'image/webp')) { + if (strpos($_SERVER['HTTP_ACCEPT'], 'image/webp') !== false) { $imgurl = $img_domain . "/manifest/" . $img_array[$img]["webp"][0]; } else { $imgurl = $img_domain . "/manifest/" . $img_array[$img]["jpeg"][0]; From c9a041eee30d8fc5cec60f368c6448be07a6599e Mon Sep 17 00:00:00 2001 From: Spirit Date: Mon, 3 Aug 2020 14:01:19 +0800 Subject: [PATCH 3/3] fix: fix comment link disable auto linking of URLs in comments fix #230 --- functions.php | 1 + inc/Parsedown.php | 27 +++++++++++++++++++++++---- 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/functions.php b/functions.php index 74382a7..91bcb1e 100644 --- a/functions.php +++ b/functions.php @@ -1817,6 +1817,7 @@ function markdown_parser($incoming_comment) return $incoming_comment; } add_filter('preprocess_comment', 'markdown_parser'); +remove_filter( 'comment_text', 'make_clickable', 9 ); //保存Markdown评论 function save_markdown_comment($comment_ID, $comment_approved) diff --git a/inc/Parsedown.php b/inc/Parsedown.php index a34b44f..1b9d6d5 100644 --- a/inc/Parsedown.php +++ b/inc/Parsedown.php @@ -17,7 +17,7 @@ class Parsedown { # ~ - const version = '1.7.3'; + const version = '1.7.4'; # ~ @@ -1489,22 +1489,41 @@ class Parsedown } } + $permitRawHtml = false; + if (isset($Element['text'])) + { + $text = $Element['text']; + } + // very strongly consider an alternative if you're writing an + // extension + elseif (isset($Element['rawHtml'])) + { + $text = $Element['rawHtml']; + $allowRawHtmlInSafeMode = isset($Element['allowRawHtmlInSafeMode']) && $Element['allowRawHtmlInSafeMode']; + $permitRawHtml = !$this->safeMode || $allowRawHtmlInSafeMode; + } + + if (isset($text)) { $markup .= '>'; - if (!isset($Element['nonNestables'])) + if (!isset($Element['nonNestables'])) { $Element['nonNestables'] = array(); } if (isset($Element['handler'])) { - $markup .= $this->{$Element['handler']}($Element['text'], $Element['nonNestables']); + $markup .= $this->{$Element['handler']}($text, $Element['nonNestables']); + } + elseif (!$permitRawHtml) + { + $markup .= self::escape($text, true); } else { - $markup .= self::escape($Element['text'], true); + $markup .= $text; } $markup .= '';