Also use the <span> tag to determine whether an editor was used

This commit is contained in:
Kijin Sung 2017-06-29 18:53:46 +09:00
parent 3c772bf1cf
commit 2a023f0854
2 changed files with 7 additions and 1 deletions

View file

@ -616,7 +616,11 @@ function is_html_content($str)
{ {
return true; return true;
} }
$span_tag_count = preg_match_all('!<span\s+style="[^"<>]*?">.+?</span>!i', $str);
if ($span_tag_count >= 1)
{
return true;
}
return false; return false;
} }

View file

@ -176,6 +176,8 @@ class FunctionsTest extends \Codeception\TestCase\Test
$this->assertTrue(is_html_content("Hello<br />\nWorld")); $this->assertTrue(is_html_content("Hello<br />\nWorld"));
$this->assertTrue(is_html_content("<p class='foo'>Hello</p>\n<p class='bar'>World</p>")); $this->assertTrue(is_html_content("<p class='foo'>Hello</p>\n<p class='bar'>World</p>"));
$this->assertTrue(is_html_content("<div>Hello<br>\r\n\n\n\n\nWorld</div>")); $this->assertTrue(is_html_content("<div>Hello<br>\r\n\n\n\n\nWorld</div>"));
$this->assertTrue(is_html_content('This is <span style="font-style:italic">italic</span> text.'));
$this->assertFalse(is_html_content('This is an empty <span></span> tag. Most editors don\'t produce these.'));
$this->assertFalse(is_html_content("You have to use a <p> tag.")); $this->assertFalse(is_html_content("You have to use a <p> tag."));
$this->assertFalse(is_html_content("This is multiline content.\n<p> tag is here.\nOther lines are here, too.<br>\nMost lines don't have any tags.")); $this->assertFalse(is_html_content("This is multiline content.\n<p> tag is here.\nOther lines are here, too.<br>\nMost lines don't have any tags."));
$this->assertFalse(is_html_content("<p> tag is unbalanced here.\nAnother line!<br />\nAnd a dangling line...")); $this->assertFalse(is_html_content("<p> tag is unbalanced here.\nAnother line!<br />\nAnd a dangling line..."));