From 2a023f0854eb21f3a9c7e513ad56d14ad7a1e281 Mon Sep 17 00:00:00 2001 From: Kijin Sung Date: Thu, 29 Jun 2017 18:53:46 +0900 Subject: [PATCH] Also use the tag to determine whether an editor was used --- common/functions.php | 6 +++++- tests/unit/functions/FunctionsTest.php | 2 ++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/common/functions.php b/common/functions.php index 046586c75..80a9dfbc4 100644 --- a/common/functions.php +++ b/common/functions.php @@ -616,7 +616,11 @@ function is_html_content($str) { return true; } - + $span_tag_count = preg_match_all('!]*?">.+?!i', $str); + if ($span_tag_count >= 1) + { + return true; + } return false; } diff --git a/tests/unit/functions/FunctionsTest.php b/tests/unit/functions/FunctionsTest.php index 8c5755435..03fdc20da 100644 --- a/tests/unit/functions/FunctionsTest.php +++ b/tests/unit/functions/FunctionsTest.php @@ -176,6 +176,8 @@ class FunctionsTest extends \Codeception\TestCase\Test $this->assertTrue(is_html_content("Hello
\nWorld")); $this->assertTrue(is_html_content("

Hello

\n

World

")); $this->assertTrue(is_html_content("
Hello
\r\n\n\n\n\nWorld
")); + $this->assertTrue(is_html_content('This is italic text.')); + $this->assertFalse(is_html_content('This is an empty tag. Most editors don\'t produce these.')); $this->assertFalse(is_html_content("You have to use a

tag.")); $this->assertFalse(is_html_content("This is multiline content.\n

tag is here.\nOther lines are here, too.
\nMost lines don't have any tags.")); $this->assertFalse(is_html_content("

tag is unbalanced here.\nAnother line!
\nAnd a dangling line..."));