Fix #741 do not allow empty HTML content in document and comment

This commit is contained in:
Kijin Sung 2017-03-06 10:50:06 +09:00
parent 29f2f6a47f
commit 387dd1f78b
6 changed files with 49 additions and 0 deletions

View file

@ -608,3 +608,18 @@ function utf8_trim($str)
{
return preg_replace('/^[\s\pZ\pC]+|[\s\pZ\pC]+$/u', '', $str);
}
/**
* Check if HTML content is empty.
* This function checks whether any printable characters remain
* after removing all tags except images, videos, iframes, etc.
*
* @param string $str The input string
* @return bool
*/
function is_empty_html_content($str)
{
$str = strip_tags($str, '<img><audio><video><iframe><object><embed>');
$str = utf8_trim(utf8_clean(html_entity_decode($str, ENT_QUOTES, 'UTF-8')));
return $str === '';
}

View file

@ -241,6 +241,7 @@ $lang->msg_module_is_not_exists = 'Cannot find the page you requested. Ask your
$lang->msg_module_is_not_standalone = 'Requested page cannot be executed independently.';
$lang->msg_empty_search_target = 'Cannot find the Search target.';
$lang->msg_empty_search_keyword = 'Cannot find the Keyword.';
$lang->msg_empty_content = 'The content is empty.';
$lang->msg_server_error = 'Server Error';
$lang->msg_server_error_see_log = 'Your server is configured to hide error messages. Please see your server\'s error log for details.';
$lang->comment_to_be_approved = 'Your comment must be approved by admin before being published.';

View file

@ -241,6 +241,7 @@ $lang->msg_module_is_not_exists = '요청한 페이지를 찾을 수 없습니
$lang->msg_module_is_not_standalone = '요청한 페이지는 독립적으로 동작할 수 없습니다.';
$lang->msg_empty_search_target = '검색대상이 없습니다.';
$lang->msg_empty_search_keyword = '검색어가 없습니다.';
$lang->msg_empty_content = '내용이 없습니다.';
$lang->msg_server_error = '서버 오류';
$lang->msg_server_error_see_log = '오류 메시지를 표시하지 않도록 설정되어 있습니다. 서버의 에러 로그에서 자세한 내용을 확인해 주십시오.';
$lang->comment_to_be_approved = '관리자의 확인이 필요한 댓글입니다.';