From b960ecec4aad81b6b9e2df5400ed45def5611685 Mon Sep 17 00:00:00 2001 From: joyqi Date: Tue, 10 Dec 2013 15:19:04 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E5=B9=B2=E6=8E=89create=5Ffunction?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- var/MarkdownExtraExtended.php | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/var/MarkdownExtraExtended.php b/var/MarkdownExtraExtended.php index 7558c6f9..674d089a 100644 --- a/var/MarkdownExtraExtended.php +++ b/var/MarkdownExtraExtended.php @@ -1516,7 +1516,7 @@ class Markdown { foreach ($blocks as $block) { # Calculate amount of space, insert spaces, insert block. $amount = $this->tab_width - - $strlen($line, 'UTF-8') % $this->tab_width; + call_user_func($strlen, $line, 'UTF-8') % $this->tab_width; $line .= str_repeat(" ", $amount) . $block; } return $line; @@ -1529,11 +1529,15 @@ class Markdown { # regular expression. # if (function_exists($this->utf8_strlen)) return; - $this->utf8_strlen = create_function('$text', 'return preg_match_all( - "/[\\\\x00-\\\\xBF]|[\\\\xC0-\\\\xFF][\\\\x80-\\\\xBF]*/", - $text, $m);'); + $this->utf8_strlen = array($this, '_utf8_strlen'); } + protected function _utf8_strlen($text) { + return preg_match_all( + "/[\\x00-\\xBF]|[\\xC0-\\xFF][\\x80-\\xBF]*/", + $text, $m); + } + protected function unhash($text) { # @@ -2174,7 +2178,7 @@ class MarkdownExtra extends Markdown { # Calculate indent before tag. if (preg_match('/(?:^|\n)( *?)(?! ).*?$/', $block_text, $matches)) { $strlen = $this->utf8_strlen; - $indent = $strlen($matches[1], 'UTF-8'); + $indent = call_user_func($strlen, $matches[1], 'UTF-8'); } else { $indent = 0; } From e7ba0057d5935f46f2e4e22f57e8c2ffaa9bd9a4 Mon Sep 17 00:00:00 2001 From: joyqi Date: Tue, 10 Dec 2013 15:26:17 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E4=BF=AE=E6=AD=A3=E8=AF=84=E8=AE=BA?= =?UTF-8?q?=E6=A3=80=E6=B5=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- var/Widget/Archive.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/var/Widget/Archive.php b/var/Widget/Archive.php index f36ea0aa..42552643 100644 --- a/var/Widget/Archive.php +++ b/var/Widget/Archive.php @@ -619,7 +619,10 @@ class Widget_Archive extends Widget_Abstract_Contents $permalink = Typecho_Common::url($path, $this->options->index); $requestUrl = $this->request->getRequestUrl(); - if ($permalink != $requestUrl) { + $src = parse_url($permalink); + $target = parse_url($requestUrl); + + if ($src['host'] != $target['host'] || $src['path'] != $target['path']) { $this->response->redirect($permalink, true); } }