From d0fb23a107aa5d3e2e032459b3ac6d1c5170e1b0 Mon Sep 17 00:00:00 2001 From: skratte Date: Sun, 19 Nov 2017 19:42:32 +0100 Subject: [PATCH 1/5] Remove mbstring dependency The dependency to mbstring in php7 could be removed with a fallback to strlen. --- Parsedown.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/Parsedown.php b/Parsedown.php index 757666e00..967a1b173 100644 --- a/Parsedown.php +++ b/Parsedown.php @@ -141,7 +141,14 @@ protected function lines(array $lines) foreach ($parts as $part) { - $shortage = 4 - mb_strlen($line, 'utf-8') % 4; + if(function_exists('mb_strlen')) + { + $shortage = 4 - mb_strlen($line, 'utf8') % 4; + } + else + { + $shortage = 4 - strlen($line) % 4; + } $line .= str_repeat(' ', $shortage); $line .= $part; From 1e3740aa67b38025458d87321b015b55a6eafef4 Mon Sep 17 00:00:00 2001 From: skratte Date: Thu, 23 Nov 2017 16:37:01 +0100 Subject: [PATCH 2/5] Update Parsedown.php --- Parsedown.php | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/Parsedown.php b/Parsedown.php index 967a1b173..1457d9156 100644 --- a/Parsedown.php +++ b/Parsedown.php @@ -141,13 +141,17 @@ protected function lines(array $lines) foreach ($parts as $part) { - if(function_exists('mb_strlen')) - { - $shortage = 4 - mb_strlen($line, 'utf8') % 4; + if(function_exists(mb_strlen)) + { + $shortage = 4 - mb_strlen($line, 'UTF-8') % 4; + } + elseif(function_exists(iconv_strlen)) + { + $shortage = 4 - iconv_strlen($line, 'UTF-8') % 4; } else { - $shortage = 4 - strlen($line) % 4; + $shortage = 4 - preg_match_all("/.{1}/us",$line) % 4; } $line .= str_repeat(' ', $shortage); From f239a72237f64a3873e6c42364b4bb96f2f31b35 Mon Sep 17 00:00:00 2001 From: skratte Date: Thu, 23 Nov 2017 17:03:45 +0100 Subject: [PATCH 3/5] Update Parsedown.php --- Parsedown.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Parsedown.php b/Parsedown.php index 1457d9156..b9e227b24 100644 --- a/Parsedown.php +++ b/Parsedown.php @@ -142,11 +142,11 @@ protected function lines(array $lines) foreach ($parts as $part) { if(function_exists(mb_strlen)) - { + { $shortage = 4 - mb_strlen($line, 'UTF-8') % 4; } elseif(function_exists(iconv_strlen)) - { + { $shortage = 4 - iconv_strlen($line, 'UTF-8') % 4; } else From 05a55863a02586df24e78abc22422b11bc8ba0be Mon Sep 17 00:00:00 2001 From: skratte Date: Thu, 23 Nov 2017 17:06:56 +0100 Subject: [PATCH 4/5] Update Parsedown.php --- Parsedown.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Parsedown.php b/Parsedown.php index b9e227b24..dcb34a3c1 100644 --- a/Parsedown.php +++ b/Parsedown.php @@ -141,11 +141,11 @@ protected function lines(array $lines) foreach ($parts as $part) { - if(function_exists(mb_strlen)) + if(function_exists('mb_strlen')) { $shortage = 4 - mb_strlen($line, 'UTF-8') % 4; } - elseif(function_exists(iconv_strlen)) + elseif(function_exists('iconv_strlen')) { $shortage = 4 - iconv_strlen($line, 'UTF-8') % 4; } From 7fa1cfe97fee5df935c2aeb6c6eddcd73d7c23cf Mon Sep 17 00:00:00 2001 From: skratte Date: Thu, 23 Nov 2017 18:01:59 +0100 Subject: [PATCH 5/5] Update Parsedown.php --- Parsedown.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Parsedown.php b/Parsedown.php index dcb34a3c1..219158b80 100644 --- a/Parsedown.php +++ b/Parsedown.php @@ -147,7 +147,7 @@ protected function lines(array $lines) } elseif(function_exists('iconv_strlen')) { - $shortage = 4 - iconv_strlen($line, 'UTF-8') % 4; + $shortage = 4 - @iconv_strlen($line, 'UTF-8') % 4; } else {