From da0ad3bd393152f1080a434104e0af681eac367d Mon Sep 17 00:00:00 2001 From: conory Date: Thu, 13 Jul 2017 00:46:28 +0900 Subject: [PATCH 01/16] =?UTF-8?q?=EC=97=90=EB=94=94=ED=84=B0=20=EB=AA=A8?= =?UTF-8?q?=EB=93=88=EC=97=90=20HTML=20=ED=97=88=EC=9A=A9=20=EC=84=A4?= =?UTF-8?q?=EC=A0=95=20=EC=B6=94=EA=B0=80=20=ED=9A=8C=EC=9B=90=20=EB=AA=A8?= =?UTF-8?q?=EB=93=88=EC=97=90=EB=8F=84=20no=20html=20=EC=84=9C=EB=AA=85?= =?UTF-8?q?=EC=9D=84=20=EC=9C=84=ED=95=9C=20=EC=98=B5=EC=85=98=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/comment/comment.controller.php | 55 ++----------------- modules/comment/comment.model.php | 36 ++++++++++++ modules/document/document.controller.php | 48 +--------------- modules/document/document.model.php | 38 ++++++++++++- modules/editor/editor.controller.php | 14 ++--- modules/editor/editor.model.php | 6 +- modules/editor/lang/en.php | 1 + modules/editor/lang/ko.php | 1 + .../editor/skins/textarea/css/textarea.css | 6 +- modules/editor/skins/textarea/editor.html | 7 ++- modules/editor/tpl/editor_module_config.html | 7 +++ modules/member/lang/en.php | 2 + modules/member/lang/ko.php | 4 +- modules/member/member.admin.controller.php | 3 +- modules/member/member.admin.view.php | 1 + modules/member/member.controller.php | 26 +++++---- modules/member/member.model.php | 17 +++++- modules/member/member.view.php | 2 + modules/member/tpl/default_config.html | 8 --- modules/member/tpl/signup_config.html | 39 ++++++++++--- 20 files changed, 179 insertions(+), 142 deletions(-) diff --git a/modules/comment/comment.controller.php b/modules/comment/comment.controller.php index b0530fda7..0434b77e4 100644 --- a/modules/comment/comment.controller.php +++ b/modules/comment/comment.controller.php @@ -358,7 +358,9 @@ class commentController extends comment { return new Object(-1, 'msg_invalid_document'); } - + + // creat the comment model object + $oCommentModel = getModel('comment'); // get a object of document model $oDocumentModel = getModel('document'); @@ -436,28 +438,7 @@ class commentController extends comment // if use editor of nohtml, Remove HTML tags from the contents. if(!$manual_inserted) { - $editor_config = getModel('editor')->getEditorConfig($obj->module_srl); - if (strpos($editor_config->sel_comment_editor_colorset, 'nohtml') !== false) - { - $is_html_content = false; - } - elseif ($obj->use_editor === 'Y' || $obj->use_html === 'Y') - { - $is_html_content = true; - } - elseif ($obj->use_editor === 'N' || $obj->use_html === 'N') - { - $is_html_content = false; - } - else - { - $is_html_content = is_html_content($obj->content); - } - - if (!$is_html_content) - { - $obj->content = nl2br($obj->use_html === 'Y' ? $obj->content : escape($obj->content, false)); - } + $obj->content = $oCommentModel->filterHtml($obj); } if(!$obj->regdate) @@ -558,10 +539,7 @@ class commentController extends comment $oDB->rollback(); return $output; } - - // creat the comment model object - $oCommentModel = getModel('comment'); - + // get the number of all comments in the posting $comment_count = $oCommentModel->getCommentCount($document_srl); @@ -810,28 +788,7 @@ class commentController extends comment // if use editor of nohtml, Remove HTML tags from the contents. if(!$manual_updated) { - $editor_config = getModel('editor')->getEditorConfig($obj->module_srl); - if (strpos($editor_config->sel_comment_editor_colorset, 'nohtml') !== false) - { - $is_html_content = false; - } - elseif ($obj->use_editor === 'Y' || $obj->use_html === 'Y') - { - $is_html_content = true; - } - elseif ($obj->use_editor === 'N' || $obj->use_html === 'N') - { - $is_html_content = false; - } - else - { - $is_html_content = is_html_content($obj->content); - } - - if (!$is_html_content) - { - $obj->content = nl2br($obj->use_html === 'Y' ? $obj->content : escape($obj->content, false)); - } + $obj->content = $oCommentModel->filterHtml($obj); } // remove iframe and script if not a top administrator on the session diff --git a/modules/comment/comment.model.php b/modules/comment/comment.model.php index 746d521cc..c2c78c79a 100644 --- a/modules/comment/comment.model.php +++ b/modules/comment/comment.model.php @@ -951,6 +951,42 @@ class commentModel extends comment return $comment_config; } + + /** + * Return filtered content + * @param object $obj + * @return string + */ + function filterHtml($obj) + { + $no_html = false; + $editor_config = getModel('editor')->getEditorConfig($obj->module_srl); + + if ($editor_config->allow_html === 'N') + { + $no_html = true; + } + elseif (strpos($editor_config->sel_comment_editor_colorset, 'nohtml') !== false) + { + $no_html = true; + } + elseif ($obj->use_html === 'N') + { + $no_html = true; + } + + if ($no_html || $obj->use_editor === 'N' || !is_html_content($obj->content)) + { + if ($no_html) + { + $obj->content = escape(strip_tags($obj->content), false); + } + + $obj->content = nl2br($obj->content); + } + + return $obj->content; + } /** * Return a list of voting member diff --git a/modules/document/document.controller.php b/modules/document/document.controller.php index bd78e0054..22e40b960 100644 --- a/modules/document/document.controller.php +++ b/modules/document/document.controller.php @@ -457,28 +457,7 @@ class documentController extends document // if use editor of nohtml, Remove HTML tags from the contents. if(!$manual_inserted) { - $editor_config = getModel('editor')->getEditorConfig($obj->module_srl); - if (strpos($editor_config->sel_editor_colorset, 'nohtml') !== false) - { - $is_html_content = false; - } - elseif ($obj->use_editor === 'Y' || $obj->use_html === 'Y') - { - $is_html_content = true; - } - elseif ($obj->use_editor === 'N' || $obj->use_html === 'N') - { - $is_html_content = false; - } - else - { - $is_html_content = is_html_content($obj->content); - } - - if (!$is_html_content) - { - $obj->content = nl2br($obj->use_html === 'Y' ? $obj->content : escape($obj->content, false)); - } + $obj->content = $oDocumentModel->filterHtml($obj); } // Remove iframe and script if not a top adminisrator in the session. @@ -716,30 +695,9 @@ class documentController extends document // if use editor of nohtml, Remove HTML tags from the contents. if(!$manual_updated) { - $editor_config = getModel('editor')->getEditorConfig($obj->module_srl); - if (strpos($editor_config->sel_editor_colorset, 'nohtml') !== false) - { - $is_html_content = false; - } - elseif ($obj->use_editor === 'Y' || $obj->use_html === 'Y') - { - $is_html_content = true; - } - elseif ($obj->use_editor === 'N' || $obj->use_html === 'N') - { - $is_html_content = false; - } - else - { - $is_html_content = is_html_content($obj->content); - } - - if (!$is_html_content) - { - $obj->content = nl2br($obj->use_html === 'Y' ? $obj->content : escape($obj->content, false)); - } + $obj->content = $oDocumentModel->filterHtml($obj); } - + // Change not extra vars but language code of the original document if document's lang_code is different from author's setting. if($source_obj->get('lang_code') != Context::getLangType()) { diff --git a/modules/document/document.model.php b/modules/document/document.model.php index 8c33bbbe0..73b658c32 100644 --- a/modules/document/document.model.php +++ b/modules/document/document.model.php @@ -1246,7 +1246,43 @@ class documentModel extends document return array_flip($this->getStatusList()); else return $lang->status_name_list; } - + + /** + * Return filtered content + * @param object $obj + * @return string + */ + function filterHtml($obj) + { + $no_html = false; + $editor_config = getModel('editor')->getEditorConfig($obj->module_srl); + + if ($editor_config->allow_html === 'N') + { + $no_html = true; + } + elseif (strpos($editor_config->sel_editor_colorset, 'nohtml') !== false) + { + $no_html = true; + } + elseif ($obj->use_html === 'N') + { + $no_html = true; + } + + if ($no_html || $obj->use_editor === 'N' || !is_html_content($obj->content)) + { + if ($no_html) + { + $obj->content = escape(strip_tags($obj->content), false); + } + + $obj->content = nl2br($obj->content); + } + + return $obj->content; + } + /** * Setting sort index * @param object $obj diff --git a/modules/editor/editor.controller.php b/modules/editor/editor.controller.php index 89b22b672..9adea2977 100644 --- a/modules/editor/editor.controller.php +++ b/modules/editor/editor.controller.php @@ -147,21 +147,21 @@ class editorController extends editor $editor_config->{$key} = explode('|@|', $grant); } } - + $editor_config->editor_height = (int)Context::get('editor_height'); $editor_config->comment_editor_height = (int)Context::get('comment_editor_height'); - $editor_config->enable_autosave = Context::get('enable_autosave'); - if($editor_config->enable_autosave != 'Y') $editor_config->enable_autosave = 'N'; - + $editor_config->enable_autosave = Context::get('enable_autosave') ?: 'N'; + $editor_config->allow_html = Context::get('allow_html') ?: 'Y'; + $oModuleController = getController('module'); foreach ($module_srl as $srl) { - $oModuleController->insertModulePartConfig('editor',$srl,$editor_config); + $oModuleController->insertModulePartConfig('editor', $srl, $editor_config); } - + $this->setError(-1); $this->setMessage('success_updated', 'info'); - + $returnUrl = Context::get('success_return_url') ? Context::get('success_return_url') : getNotEncodedUrl('', 'module', 'admin', 'act', 'dispBoardAdminContent'); $this->setRedirectUrl($returnUrl); } diff --git a/modules/editor/editor.model.php b/modules/editor/editor.model.php index 3aa02d2b7..36069852d 100644 --- a/modules/editor/editor.model.php +++ b/modules/editor/editor.model.php @@ -43,7 +43,8 @@ class editorModel extends editor } // Fill in some other values. - if($editor_config->enable_autosave != 'N') $editor_config->enable_autosave = 'Y'; + $editor_config->enable_autosave = $editor_config->enable_autosave ?: 'Y'; + $editor_config->allow_html = $editor_config->allow_html ?: 'Y'; if(!is_array($editor_config->enable_html_grant)) $editor_config->enable_html_grant = array(); if(!is_array($editor_config->enable_comment_html_grant)) $editor_config->enable_comment_html_grant = array(); if(!is_array($editor_config->upload_file_grant)) $editor_config->upload_file_grant = array(); @@ -252,6 +253,9 @@ class editorModel extends editor } Context::set('enable_autosave', $option->enable_autosave); + // Set allow html + Context::set('allow_html', ($option->allow_html === false || $option->allow_html === 'N') ? false : true); + // Load editor components. $site_srl = Context::get('site_module_info')->site_srl ?: 0; if($option->editor_skin === 'dreditor') diff --git a/modules/editor/lang/en.php b/modules/editor/lang/en.php index 1ab1bc11b..d970c3066 100644 --- a/modules/editor/lang/en.php +++ b/modules/editor/lang/en.php @@ -71,6 +71,7 @@ $lang->enable_default_component_grant = 'Permission to use default components'; $lang->enable_extra_component_grant = 'Permission to use extra components'; $lang->enable_html_grant = 'Permission to edit HTML'; $lang->enable_autosave = 'Enable Auto-Save'; +$lang->allow_html = 'allow HTML'; $lang->height_resizable = 'Height Resizable'; $lang->editor_height = 'Height of Editor'; $lang->about_default_editor_settings = 'Follow editor settings of Rhymix Admin page through whole site.'; diff --git a/modules/editor/lang/ko.php b/modules/editor/lang/ko.php index e6638f6ed..325bda73c 100644 --- a/modules/editor/lang/ko.php +++ b/modules/editor/lang/ko.php @@ -75,6 +75,7 @@ $lang->enable_default_component_grant = '기본 컴포넌트 사용 권한'; $lang->enable_extra_component_grant = '확장 컴포넌트 사용 권한'; $lang->enable_html_grant = 'HTML 편집 권한'; $lang->enable_autosave = '자동저장 사용'; +$lang->allow_html = 'HTML 허용'; $lang->height_resizable = '높이 조절 가능'; $lang->editor_height = '에디터 높이'; $lang->about_default_editor_settings = '사이트 전체 에디터 설정을 통일하여서 모듈별 에디터 설정을 단순하게 합니다.'; diff --git a/modules/editor/skins/textarea/css/textarea.css b/modules/editor/skins/textarea/css/textarea.css index 7cb65f24a..74622abd9 100644 --- a/modules/editor/skins/textarea/css/textarea.css +++ b/modules/editor/skins/textarea/css/textarea.css @@ -1,8 +1,3 @@ - -.rx_editor_wrapper { - clear: both; -} - .rx_editor_wrapper .rx_editor_textarea { width: 100%; min-height: 64px; @@ -16,4 +11,5 @@ .rx_editor_wrapper .rx_editor_textarea.dark { border-color: #111; background: #333; + color: #fff; } diff --git a/modules/editor/skins/textarea/editor.html b/modules/editor/skins/textarea/editor.html index af006faef..4d5732235 100644 --- a/modules/editor/skins/textarea/editor.html +++ b/modules/editor/skins/textarea/editor.html @@ -27,6 +27,11 @@ } // Save edited content + + textarea.on("change", function() { + content_input.val(String($(this).val()).escape()); + }); + textarea.on("change", function() { content_input.val("

" + String($(this).val()).escape().replace(/\r?\n/g, "

\n

") + "

"); }); @@ -45,7 +50,7 @@ } else { parentform.append(''); } - + }); diff --git a/modules/editor/tpl/editor_module_config.html b/modules/editor/tpl/editor_module_config.html index 6cfdc6802..0a53d0979 100644 --- a/modules/editor/tpl/editor_module_config.html +++ b/modules/editor/tpl/editor_module_config.html @@ -89,6 +89,13 @@ + + {$lang->allow_html} + + + + + {$lang->enable_html_grant} diff --git a/modules/member/lang/en.php b/modules/member/lang/en.php index f2b38652e..725155d3b 100644 --- a/modules/member/lang/en.php +++ b/modules/member/lang/en.php @@ -74,6 +74,8 @@ $lang->options = 'Options'; $lang->about_keep_signed = 'You will be still signed in even when the browser is closed.\\n\\nIt is not recommended to use this if you are using a public computer, for your personal information could be violated.'; $lang->about_keep_warning = 'You will be still signed in even when the browser is closed. It is not recommended to use this if you are using a public computer, for your personal information could be violated'; $lang->about_webmaster_email = 'This setting can be changed in the Notification Settings screen.'; +$lang->retroactive_application = 'retroact'; +$lang->signature_html_retroact = 'also remove HTML in past inseted HTML signature. Can not be reversed.'; $lang->search_target_list['email_address'] = 'Email Address'; $lang->search_target_list['regdate'] = 'Sign up Date'; $lang->search_target_list['regdate_more'] = 'Sign up Date (more)'; diff --git a/modules/member/lang/ko.php b/modules/member/lang/ko.php index 0a21ca2f5..bbf2e0bef 100644 --- a/modules/member/lang/ko.php +++ b/modules/member/lang/ko.php @@ -76,6 +76,8 @@ $lang->options = '선택 옵션'; $lang->about_keep_signed = '브라우저를 닫더라도 로그인이 계속 유지될 수 있습니다.\\n\\n로그인 유지 기능을 사용할 경우 다음 접속부터는 로그인할 필요가 없습니다.\\n\\n단, PC방, 학교, 도서관 등 공공장소에서 이용 시 개인정보가 유출될 수 있으니 꼭 로그아웃을 해주세요.'; $lang->about_keep_warning = '브라우저를 닫더라도 로그인이 계속 유지될 수 있습니다. 로그인 유지 기능을 사용할 경우 다음 접속부터는 로그인할 필요가 없습니다. 단, PC방, 학교, 도서관 등 공공장소에서 이용 시 개인정보가 유출될 수 있으니 꼭 로그아웃을 해주세요.'; $lang->about_webmaster_email = '이 설정은 알림 설정 화면에서 변경할 수 있습니다.'; +$lang->retroactive_application = '소급적용'; +$lang->signature_html_retroact = '이전에 입력된 HTML 서명에서도 HTML을 제거 합니다. 되돌릴 수 없습니다.'; $lang->search_target_list['email_address'] = '이메일'; $lang->search_target_list['regdate'] = '가입일시'; $lang->search_target_list['regdate_more'] = '가입일시(이상)'; @@ -120,7 +122,6 @@ $lang->cmd_view_scrapped_document = '스크랩 보기'; $lang->cmd_view_saved_document = '저장함 보기'; $lang->cmd_send_email = '메일 보내기'; $lang->cmd_modify_nickname_log = '닉네임 변경 기록'; -$lang->cmd_member_file_upload = '서명에 파일 첨부 사용'; $lang->cmd_member_profile_view = '회원 프로필사진 보이기'; $lang->msg_email_not_exists = '이메일 주소가 존재하지 않습니다.'; $lang->msg_alreay_scrapped = '이미 스크랩된 게시물입니다.'; @@ -170,7 +171,6 @@ $lang->msg_admin_ip_not_allowed = '접속하신 IP 주소에서는 관리자 로 $lang->about_rechecked_password = '회원의 정보를 안전하게 보호하기 위해 비밀번호를 다시 한번 확인 합니다.'; $lang->about_user_id = '회원 ID는 3~20자 사이의 영문+숫자로 이루어져야 하며 영문으로 시작해야 합니다.'; $lang->about_password = '비밀번호는 6~20자로 되어야 합니다.'; -$lang->about_member_file_upload = '회원정보의 서명에 파일을 첨부할 수 있도록 합니다.'; $lang->cmd_config_password_strength = '비밀번호 보안수준'; $lang->cmd_password_hashing_algorithm = '비밀번호 암호화 알고리듬'; $lang->cmd_password_hashing_work_factor = '비밀번호 암호화 소요시간'; diff --git a/modules/member/member.admin.controller.php b/modules/member/member.admin.controller.php index 9013515e9..efd718195 100644 --- a/modules/member/member.admin.controller.php +++ b/modules/member/member.admin.controller.php @@ -186,7 +186,6 @@ class memberAdminController extends member 'password_hashing_auto_upgrade', 'password_change_invalidate_other_sessions', 'update_nickname_log', - 'member_allow_fileupload', 'member_profile_view' ); @@ -261,7 +260,7 @@ class memberAdminController extends member 'profile_image', 'profile_image_max_width', 'profile_image_max_height', 'image_name', 'image_name_max_width', 'image_name_max_height', 'image_mark', 'image_mark_max_width', 'image_mark_max_height', - 'signature_editor_skin', 'sel_editor_colorset' + 'signature_editor_skin', 'sel_editor_colorset', 'signature_html', 'signature_html_retroact', 'member_allow_fileupload' ); $list_order = Context::get('list_order'); diff --git a/modules/member/member.admin.view.php b/modules/member/member.admin.view.php index 4c9db1f72..d61789bef 100644 --- a/modules/member/member.admin.view.php +++ b/modules/member/member.admin.view.php @@ -387,6 +387,7 @@ class memberAdminView extends member $option = new stdClass; $option->primary_key_name = 'member_srl'; $option->content_key_name = 'signature'; + $option->allow_html = $member_config->signature_html !== 'N'; $option->allow_fileupload = $member_config->member_allow_fileupload === 'Y'; $option->enable_autosave = false; $option->enable_default_component = true; diff --git a/modules/member/member.controller.php b/modules/member/member.controller.php index 12799a602..f48dcfd4c 100644 --- a/modules/member/member.controller.php +++ b/modules/member/member.controller.php @@ -1618,18 +1618,22 @@ class memberController extends member */ function putSignature($member_srl, $signature) { - $signature = trim(removeHackTag($signature)); - $signature = preg_replace('/<(\/?)(embed|object|param)/is', '<$1$2', $signature); - - $check_signature = trim(str_replace(array(' ',"\n","\r"),'',strip_tags($signature,''))); - $path = sprintf('files/member_extra_info/signature/%s/', getNumberingPath($member_srl)); - $filename = sprintf('%s%d.signature.php', $path, $member_srl); - - if(!$check_signature) return FileHandler::removeFile($filename); - + if((!$signature = trim(removeHackTag($signature))) || is_empty_html_content($signature)) + { + getController('member')->delSignature($member_srl); + return; + } + + if(getModel('member')->getMemberConfig()->signature_html == 'N') + { + $signature = nl2br(escape(strip_tags($signature), false)); + } + + $filename = sprintf('files/member_extra_info/signature/%s%d.signature.php', getNumberingPath($member_srl), $member_srl); $buff = sprintf('%s', $signature); - FileHandler::makeDir($path); - FileHandler::writeFile($filename, $buff); + Rhymix\Framework\Storage::write($filename, $buff); + + return $signature; } /** diff --git a/modules/member/member.model.php b/modules/member/member.model.php index 6d86ca404..ace821b5e 100644 --- a/modules/member/member.model.php +++ b/modules/member/member.model.php @@ -1030,12 +1030,23 @@ class memberModel extends member $filename = sprintf('files/member_extra_info/signature/%s%d.signature.php', getNumberingPath($member_srl), $member_srl); if(file_exists($filename)) { - $buff = FileHandler::readFile($filename); - $signature = preg_replace('/<\?.*\?>/', '', $buff); + $signature = preg_replace('/<\?.*\?>/', '', FileHandler::readFile($filename)); + + // retroact + $config = getModel('member')->getMemberConfig(); + if($config->signature_html_retroact == 'Y' && $config->signature_html == 'N' && preg_match('/<[^br]+>/i', $signature)) + { + return getController('member')->putSignature($member_srl, $signature); + } + $GLOBALS['__member_info__']['signature'][$member_srl] = $signature; } - else $GLOBALS['__member_info__']['signature'][$member_srl] = null; + else + { + $GLOBALS['__member_info__']['signature'][$member_srl] = ''; + } } + return $GLOBALS['__member_info__']['signature'][$member_srl]; } diff --git a/modules/member/member.view.php b/modules/member/member.view.php index 94d973686..9fa7a5475 100644 --- a/modules/member/member.view.php +++ b/modules/member/member.view.php @@ -217,6 +217,7 @@ class memberView extends member $option = new stdClass; $option->primary_key_name = 'member_srl'; $option->content_key_name = 'signature'; + $option->allow_html = $member_config->signature_html !== 'N'; $option->allow_fileupload = false; $option->enable_autosave = false; $option->enable_default_component = true; @@ -314,6 +315,7 @@ class memberView extends member $option = new stdClass; $option->primary_key_name = 'member_srl'; $option->content_key_name = 'signature'; + $option->allow_html = $member_config->signature_html !== 'N'; $option->allow_fileupload = $member_config->member_allow_fileupload === 'Y'; $option->enable_autosave = false; $option->enable_default_component = true; diff --git a/modules/member/tpl/default_config.html b/modules/member/tpl/default_config.html index 85d8c9818..463ea41b9 100644 --- a/modules/member/tpl/default_config.html +++ b/modules/member/tpl/default_config.html @@ -108,14 +108,6 @@

{$lang->about_member_sync}

-
- -
- - -

{$lang->about_member_file_upload}

-
-
diff --git a/modules/member/tpl/signup_config.html b/modules/member/tpl/signup_config.html index 1e7de04ef..eafa00e63 100644 --- a/modules/member/tpl/signup_config.html +++ b/modules/member/tpl/signup_config.html @@ -152,15 +152,40 @@   From 820c725d698fb1cc034c729fe7d00c0fdd310ad0 Mon Sep 17 00:00:00 2001 From: conory Date: Thu, 13 Jul 2017 11:15:12 +0900 Subject: [PATCH 02/16] =?UTF-8?q?convertHTML()=20=EB=A1=9C=20=EB=B3=80?= =?UTF-8?q?=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/comment/comment.controller.php | 10 +++---- modules/comment/comment.model.php | 36 ------------------------ modules/document/document.controller.php | 6 ++-- modules/document/document.model.php | 36 ------------------------ modules/editor/editor.model.php | 36 ++++++++++++++++++++++++ 5 files changed, 44 insertions(+), 80 deletions(-) diff --git a/modules/comment/comment.controller.php b/modules/comment/comment.controller.php index 0434b77e4..80c811adc 100644 --- a/modules/comment/comment.controller.php +++ b/modules/comment/comment.controller.php @@ -438,9 +438,9 @@ class commentController extends comment // if use editor of nohtml, Remove HTML tags from the contents. if(!$manual_inserted) { - $obj->content = $oCommentModel->filterHtml($obj); + $obj->content = getModel('editor')->convertHTML($obj); } - + if(!$obj->regdate) { $obj->regdate = date("YmdHis"); @@ -784,13 +784,13 @@ class commentController extends comment { return new Object(-1, 'msg_empty_content'); } - + // if use editor of nohtml, Remove HTML tags from the contents. if(!$manual_updated) { - $obj->content = $oCommentModel->filterHtml($obj); + $obj->content = getModel('editor')->convertHTML($obj); } - + // remove iframe and script if not a top administrator on the session if($logged_info->is_admin != 'Y') { diff --git a/modules/comment/comment.model.php b/modules/comment/comment.model.php index c2c78c79a..d4a942969 100644 --- a/modules/comment/comment.model.php +++ b/modules/comment/comment.model.php @@ -952,42 +952,6 @@ class commentModel extends comment return $comment_config; } - /** - * Return filtered content - * @param object $obj - * @return string - */ - function filterHtml($obj) - { - $no_html = false; - $editor_config = getModel('editor')->getEditorConfig($obj->module_srl); - - if ($editor_config->allow_html === 'N') - { - $no_html = true; - } - elseif (strpos($editor_config->sel_comment_editor_colorset, 'nohtml') !== false) - { - $no_html = true; - } - elseif ($obj->use_html === 'N') - { - $no_html = true; - } - - if ($no_html || $obj->use_editor === 'N' || !is_html_content($obj->content)) - { - if ($no_html) - { - $obj->content = escape(strip_tags($obj->content), false); - } - - $obj->content = nl2br($obj->content); - } - - return $obj->content; - } - /** * Return a list of voting member * @return void diff --git a/modules/document/document.controller.php b/modules/document/document.controller.php index 22e40b960..b3f0dc699 100644 --- a/modules/document/document.controller.php +++ b/modules/document/document.controller.php @@ -457,9 +457,9 @@ class documentController extends document // if use editor of nohtml, Remove HTML tags from the contents. if(!$manual_inserted) { - $obj->content = $oDocumentModel->filterHtml($obj); + $obj->content = getModel('editor')->convertHTML($obj); } - + // Remove iframe and script if not a top adminisrator in the session. if($logged_info->is_admin != 'Y') $obj->content = removeHackTag($obj->content); // An error appears if both log-in info and user name don't exist. @@ -695,7 +695,7 @@ class documentController extends document // if use editor of nohtml, Remove HTML tags from the contents. if(!$manual_updated) { - $obj->content = $oDocumentModel->filterHtml($obj); + $obj->content = getModel('editor')->convertHTML($obj); } // Change not extra vars but language code of the original document if document's lang_code is different from author's setting. diff --git a/modules/document/document.model.php b/modules/document/document.model.php index 73b658c32..f0be0ee21 100644 --- a/modules/document/document.model.php +++ b/modules/document/document.model.php @@ -1247,42 +1247,6 @@ class documentModel extends document else return $lang->status_name_list; } - /** - * Return filtered content - * @param object $obj - * @return string - */ - function filterHtml($obj) - { - $no_html = false; - $editor_config = getModel('editor')->getEditorConfig($obj->module_srl); - - if ($editor_config->allow_html === 'N') - { - $no_html = true; - } - elseif (strpos($editor_config->sel_editor_colorset, 'nohtml') !== false) - { - $no_html = true; - } - elseif ($obj->use_html === 'N') - { - $no_html = true; - } - - if ($no_html || $obj->use_editor === 'N' || !is_html_content($obj->content)) - { - if ($no_html) - { - $obj->content = escape(strip_tags($obj->content), false); - } - - $obj->content = nl2br($obj->content); - } - - return $obj->content; - } - /** * Setting sort index * @param object $obj diff --git a/modules/editor/editor.model.php b/modules/editor/editor.model.php index 36069852d..e05a02062 100644 --- a/modules/editor/editor.model.php +++ b/modules/editor/editor.model.php @@ -869,6 +869,42 @@ class editorModel extends editor return $component_info; } + + /** + * Return converted content + * @param object $obj + * @return string + */ + function convertHTML($obj) + { + $no_html = false; + $editor_config = $this->getEditorConfig($obj->module_srl); + + if ($editor_config->allow_html === 'N') + { + $no_html = true; + } + elseif (strpos($obj->title ? $editor_config->sel_editor_colorset : $editor_config->sel_comment_editor_colorset, 'nohtml') !== false) + { + $no_html = true; + } + elseif ($obj->use_html === 'N') + { + $no_html = true; + } + + if ($no_html || $obj->use_editor === 'N' || !is_html_content($obj->content)) + { + if ($no_html) + { + $obj->content = escape(strip_tags($obj->content), false); + } + + $obj->content = nl2br($obj->content); + } + + return $obj->content; + } } /* End of file editor.model.php */ /* Location: ./modules/editor/editor.model.php */ From a8e0acc6cfff8b7f3122673b1b90eacf8299a426 Mon Sep 17 00:00:00 2001 From: conory Date: Thu, 13 Jul 2017 12:53:37 +0900 Subject: [PATCH 03/16] =?UTF-8?q?=EC=97=90=EB=94=94=ED=84=B0=20=EA=B8=B0?= =?UTF-8?q?=EB=B3=B8=20=EC=84=A4=EC=A0=95=EC=97=90=20=20'=EC=9E=90?= =?UTF-8?q?=EB=8F=99=EC=A0=80=EC=9E=A5=20=EC=82=AC=EC=9A=A9,=20HTML=20?= =?UTF-8?q?=ED=97=88=EC=9A=A9'=20=EC=84=A4=EC=A0=95=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/editor/editor.admin.controller.php | 6 ++++-- modules/editor/editor.class.php | 2 ++ modules/editor/editor.controller.php | 2 +- modules/editor/editor.model.php | 2 -- modules/editor/tpl/admin_index.html | 15 +++++++++++++++ modules/editor/tpl/editor_module_config.html | 11 +++++------ 6 files changed, 27 insertions(+), 11 deletions(-) diff --git a/modules/editor/editor.admin.controller.php b/modules/editor/editor.admin.controller.php index b0a5ccbb9..b3584c268 100644 --- a/modules/editor/editor.admin.controller.php +++ b/modules/editor/editor.admin.controller.php @@ -161,8 +161,8 @@ class editorAdminController extends editor $config->mobile_comment_editor_toolbar = $configVars->mobile_comment_editor_toolbar; $config->mobile_comment_editor_toolbar_hide = $configVars->mobile_comment_editor_toolbar_hide === 'Y' ? 'Y' : 'N'; $config->content_style = $configVars->content_style; - $config->sel_editor_colorset= $configVars->sel_editor_colorset; - $config->sel_comment_editor_colorset= $configVars->sel_comment_editor_colorset; + $config->sel_editor_colorset = $configVars->sel_editor_colorset; + $config->sel_comment_editor_colorset = $configVars->sel_comment_editor_colorset; if ($configVars->font_defined === 'Y') { @@ -227,6 +227,8 @@ class editorAdminController extends editor $config->content_paragraph_spacing = ctype_digit($config->content_paragraph_spacing) ? ($config->content_paragraph_spacing . 'px') : $config->content_paragraph_spacing; $config->content_word_break = $configVars->content_word_break; $config->content_word_break = in_array($config->content_word_break, array('normal', 'keep-all', 'break-all', 'none')) ? $config->content_word_break : 'normal'; + $config->enable_autosave = $configVars->enable_autosave ?: 'Y'; + $config->allow_html = $configVars->allow_html ?: 'Y'; $config->autoinsert_image = $configVars->autoinsert_image; $config->autoinsert_image = in_array($config->autoinsert_image, array('paragraph', 'inline', 'none')) ? $config->autoinsert_image : 'paragraph'; diff --git a/modules/editor/editor.class.php b/modules/editor/editor.class.php index ebb9d945f..2f526f885 100644 --- a/modules/editor/editor.class.php +++ b/modules/editor/editor.class.php @@ -45,6 +45,8 @@ class editor extends ModuleObject 'content_line_height' => '160%', 'content_paragraph_spacing' => '0px', 'content_word_break' => 'normal', + 'enable_autosave' => 'Y', + 'allow_html' => 'Y', 'autoinsert_image' => 'paragraph', 'additional_css' => array(), 'additional_mobile_css' => array(), diff --git a/modules/editor/editor.controller.php b/modules/editor/editor.controller.php index 9adea2977..2ceb16845 100644 --- a/modules/editor/editor.controller.php +++ b/modules/editor/editor.controller.php @@ -150,7 +150,7 @@ class editorController extends editor $editor_config->editor_height = (int)Context::get('editor_height'); $editor_config->comment_editor_height = (int)Context::get('comment_editor_height'); - $editor_config->enable_autosave = Context::get('enable_autosave') ?: 'N'; + $editor_config->enable_autosave = Context::get('enable_autosave') ?: 'Y'; $editor_config->allow_html = Context::get('allow_html') ?: 'Y'; $oModuleController = getController('module'); diff --git a/modules/editor/editor.model.php b/modules/editor/editor.model.php index e05a02062..34ebc95c5 100644 --- a/modules/editor/editor.model.php +++ b/modules/editor/editor.model.php @@ -43,8 +43,6 @@ class editorModel extends editor } // Fill in some other values. - $editor_config->enable_autosave = $editor_config->enable_autosave ?: 'Y'; - $editor_config->allow_html = $editor_config->allow_html ?: 'Y'; if(!is_array($editor_config->enable_html_grant)) $editor_config->enable_html_grant = array(); if(!is_array($editor_config->enable_comment_html_grant)) $editor_config->enable_comment_html_grant = array(); if(!is_array($editor_config->upload_file_grant)) $editor_config->upload_file_grant = array(); diff --git a/modules/editor/tpl/admin_index.html b/modules/editor/tpl/admin_index.html index 49328b4b0..97f59c7a8 100644 --- a/modules/editor/tpl/admin_index.html +++ b/modules/editor/tpl/admin_index.html @@ -212,6 +212,21 @@ +
+ +
+ + +

{$lang->about_enable_autosave}

+
+
+
+ +
+ + +
+
diff --git a/modules/editor/tpl/editor_module_config.html b/modules/editor/tpl/editor_module_config.html index 0a53d0979..b04c67075 100644 --- a/modules/editor/tpl/editor_module_config.html +++ b/modules/editor/tpl/editor_module_config.html @@ -80,16 +80,15 @@ {$lang->about_content_font_size} - + {$lang->enable_autosave} - + + +

{$lang->about_enable_autosave}

- + {$lang->allow_html} From 9204353a15ed56e75818df4d0d29437bf2725e8e Mon Sep 17 00:00:00 2001 From: conory Date: Thu, 13 Jul 2017 13:06:30 +0900 Subject: [PATCH 04/16] =?UTF-8?q?=EC=97=90=EB=94=94=ED=84=B0=20=EC=BB=AC?= =?UTF-8?q?=EB=9F=AC=EC=85=8B=20act=20=ED=8D=BC=EB=AF=B8=EC=85=98=20?= =?UTF-8?q?=EB=B3=80=EA=B2=BD=20=EB=AA=A8=EB=93=88=20=EA=B4=80=EB=A6=AC?= =?UTF-8?q?=EC=9E=90=EA=B0=80=20=EC=97=90=EB=94=94=ED=84=B0=EB=A5=BC=20?= =?UTF-8?q?=EB=B3=80=EA=B2=BD=ED=95=A0=20=EC=88=98=20=EC=97=86=EC=97=88?= =?UTF-8?q?=EB=8D=98=20=EB=AC=B8=EC=A0=9C=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/editor/conf/module.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/editor/conf/module.xml b/modules/editor/conf/module.xml index 73470d2f0..10d074053 100644 --- a/modules/editor/conf/module.xml +++ b/modules/editor/conf/module.xml @@ -5,7 +5,7 @@ - + From c72e2ad49fbf27621d9720c8fc18e52bed76c3b4 Mon Sep 17 00:00:00 2001 From: conory Date: Thu, 13 Jul 2017 15:59:00 +0900 Subject: [PATCH 05/16] =?UTF-8?q?=EC=97=90=EB=94=94=ED=84=B0=20=EB=AF=B8?= =?UTF-8?q?=EB=A6=AC=EB=B3=B4=EA=B8=B0=20=EA=B0=9C=EC=84=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/editor/editor.model.php | 23 +++++++------ modules/editor/editor.view.php | 53 ++--------------------------- modules/editor/tpl/admin_index.html | 8 ++--- 3 files changed, 19 insertions(+), 65 deletions(-) diff --git a/modules/editor/editor.model.php b/modules/editor/editor.model.php index 34ebc95c5..ea9b265b2 100644 --- a/modules/editor/editor.model.php +++ b/modules/editor/editor.model.php @@ -408,19 +408,22 @@ class editorModel extends editor } // Permission check for file upload - if ($logged_info->is_admin === 'Y' || !count($option->upload_file_grant)) + if($module_srl) { - $option->allow_fileupload = true; - } - else - { - $option->allow_fileupload = false; - foreach($group_list as $group_srl => $group_info) + if ($logged_info->is_admin === 'Y' || !count($option->upload_file_grant)) { - if(in_array($group_srl, $option->upload_file_grant)) + $option->allow_fileupload = true; + } + else + { + $option->allow_fileupload = false; + foreach($group_list as $group_srl => $group_info) { - $option->allow_fileupload = true; - break; + if(in_array($group_srl, $option->upload_file_grant)) + { + $option->allow_fileupload = true; + break; + } } } } diff --git a/modules/editor/editor.view.php b/modules/editor/editor.view.php index 01f8b5da9..678551962 100644 --- a/modules/editor/editor.view.php +++ b/modules/editor/editor.view.php @@ -149,57 +149,8 @@ class editorView extends editor function dispEditorConfigPreview() { - $oEditorModel = getModel('editor'); - $config = $oEditorModel->getEditorConfig(); - - $mode = Context::get('mode'); - - if($mode != 'main') - { - $option_com = new stdClass(); - $option_com->allow_fileupload = false; - $option_com->content_style = $config->content_style; - $option_com->content_font = $config->content_font; - $option_com->content_font_size = $config->content_font_size; - $option_com->content_line_height = $config->content_line_height; - $option_com->content_paragraph_spacing = $config->content_paragraph_spacing; - $option_com->content_word_break = $config->content_word_break; - $option_com->enable_autosave = false; - $option_com->enable_default_component = true; - $option_com->enable_component = true; - $option_com->disable_html = false; - $option_com->height = $config->comment_editor_height; - $option_com->skin = $config->comment_editor_skin; - $option_com->content_key_name = 'dummy_content'; - $option_com->primary_key_name = 'dummy_key'; - $option_com->content_style = $config->comment_content_style; - $option_com->colorset = $config->sel_comment_editor_colorset; - $editor = $oEditorModel->getEditor(0, $option_com); - } - else - { - $option = new stdClass(); - $option->allow_fileupload = false; - $option->content_style = $config->content_style; - $option->content_font = $config->content_font; - $option->content_font_size = $config->content_font_size; - $option->content_line_height = $config->content_line_height; - $option->content_paragraph_spacing = $config->content_paragraph_spacing; - $option->content_word_break = $config->content_word_break; - $option->enable_autosave = false; - $option->enable_default_component = true; - $option->enable_component = true; - $option->disable_html = false; - $option->height = $config->editor_height; - $option->skin = $config->editor_skin; - $option->content_key_name = 'dummy_content'; - $option->primary_key_name = 'dummy_key'; - $option->colorset = $config->sel_editor_colorset; - $editor = $oEditorModel->getEditor(0, $option); - } - - Context::set('editor', $editor); - + Context::set('editor', getModel('editor')->getModuleEditor(Context::get('type'), 0, 0, 'dummy_key', 'dummy_content')); + $this->setLayoutFile('popup_layout'); $this->setTemplatePath($this->module_path.'tpl'); $this->setTemplateFile('config_preview'); diff --git a/modules/editor/tpl/admin_index.html b/modules/editor/tpl/admin_index.html index 97f59c7a8..776762c8a 100644 --- a/modules/editor/tpl/admin_index.html +++ b/modules/editor/tpl/admin_index.html @@ -7,7 +7,7 @@

{$XE_VALIDATOR_MESSAGE}

-
+
From 77418672bbc280b1c05dda8d916989ff9064f3e7 Mon Sep 17 00:00:00 2001 From: conory Date: Sat, 15 Jul 2017 10:52:40 +0900 Subject: [PATCH 12/16] =?UTF-8?q?=EB=8B=A8=EC=9D=BC=20=EC=BB=A8=EB=B2=84?= =?UTF-8?q?=ED=84=B0=EB=A1=9C=20=EC=B2=98=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/editor/editor.model.php | 56 +++++++++++++-------------------- 1 file changed, 22 insertions(+), 34 deletions(-) diff --git a/modules/editor/editor.model.php b/modules/editor/editor.model.php index 24893ebb4..c501e8e73 100644 --- a/modules/editor/editor.model.php +++ b/modules/editor/editor.model.php @@ -893,8 +893,7 @@ class editorModel extends editor */ function converter($obj, $type = null) { - $converter = array(); - $add_converters = array(); + $converter = null; $config = $this->getEditorConfig($obj->module_srl); // Get editor skin @@ -904,64 +903,53 @@ class editorModel extends editor } else { - $add_converters[] = $obj->converter; + $converter = $obj->converter; $skin = $obj->editor_skin ?: $config->editor_skin; } - // Get converter from skin - $add_converters[] = $this->getSkinConfig($skin)->converter; - - // Add converter - foreach($add_converter as $name) + // if not inserted converter, Get converter from skin + if (!$converter) { - if(!$name) + $converter = $this->getSkinConfig($skin)->converter; + } + + // if not inserted converter, Check + if (!$converter) + { + if ($config->allow_html === 'N' || $obj->use_html === 'N') { - continue; + $converter = 'text'; + } + elseif (strpos($type == 'comment' ? $config->sel_comment_editor_colorset : $config->sel_editor_colorset, 'nohtml') !== false) + { + $converter = 'text'; } - if (is_array($name)) + if (!is_html_content($obj->content) || $obj->use_editor === 'N') { - $converter = array_merge($converter, $name); + $converter = 'default'; } - else - { - $converter[] = $name; - } - } - - // Check - if ($config->allow_html === 'N' || $obj->use_html === 'N') - { - $converter[] = 'text'; - } - elseif (strpos($type == 'comment' ? $config->sel_comment_editor_colorset : $config->sel_editor_colorset, 'nohtml') !== false) - { - $converter[] = 'text'; - } - if (!is_html_content($obj->content) || $obj->use_editor === 'N') - { - $converter[] = 'default'; } // Convert if ($converter) { // To Text - if (in_array('text', $converter)) + if ($converter == 'text') { $obj->content = escape(strip_tags($obj->content), false); } // To HTML - if (in_array('text2html', $converter)) + if ($converter == 'text2html') { $obj->content = Rhymix\Framework\Formatter::text2html($obj->content); } - elseif (in_array('markdown2html', $converter)) + elseif ($converter == 'markdown2html') { $obj->content = Rhymix\Framework\Formatter::markdown2html($obj->content); } - elseif (in_array('bbcode', $converter)) + elseif ($converter == 'bbcode') { $obj->content = Rhymix\Framework\Formatter::bbcode($obj->content); } From 56d62a816ffaa59eab54aae745201ecea826e203 Mon Sep 17 00:00:00 2001 From: conory Date: Sat, 15 Jul 2017 21:10:04 +0900 Subject: [PATCH 13/16] =?UTF-8?q?textarea=20=EC=97=90=EB=94=94=ED=84=B0=20?= =?UTF-8?q?=EB=AF=B8=EB=A6=AC=EB=B3=B4=EA=B8=B0=EC=97=90=EC=84=9C=20?= =?UTF-8?q?=EC=98=A4=EB=A5=98=EA=B0=80=20=EB=B0=9C=EC=83=9D=EB=90=98?= =?UTF-8?q?=EB=8A=94=20=EB=AC=B8=EC=A0=9C=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- common/js/common.js | 1 + modules/document/document.view.php | 12 +++++++- modules/editor/skins/textarea/editor.html | 16 ++++------- modules/editor/skins/textarea/js/interface.js | 16 +++++++++++ modules/editor/skins/textarea/js/textarea.js | 28 +++++++++++++++++++ 5 files changed, 61 insertions(+), 12 deletions(-) create mode 100644 modules/editor/skins/textarea/js/interface.js create mode 100644 modules/editor/skins/textarea/js/textarea.js diff --git a/common/js/common.js b/common/js/common.js index d5db12795..2f1080ea9 100644 --- a/common/js/common.js +++ b/common/js/common.js @@ -653,6 +653,7 @@ function doDocumentPreview(obj) { '
'+ ''+ ''+ + ''+ ''+ '
' ).appendTo(document.body); diff --git a/modules/document/document.view.php b/modules/document/document.view.php index f1d6bb220..987445ca2 100644 --- a/modules/document/document.view.php +++ b/modules/document/document.view.php @@ -61,11 +61,21 @@ class documentView extends document return new Object(-1, 'msg_invalid_request'); } + $content = Context::get('content'); + if(Context::get('logged_info')->is_admin != 'Y') { - Context::set('content', removeHackTag(Context::get('content'))); + $content = removeHackTag($content); } + // Editor converter + $obj = new stdClass; + $obj->content = $content; + $obj->module_srl = getModel('module')->getModuleInfoByMid(Context::get('mid'))->module_srl; + $content = getModel('editor')->converter($obj, 'document'); + + Context::set('content', $content); + $this->setTemplatePath($this->module_path.'tpl'); $this->setTemplateFile('preview_page'); Context::set('layout', 'none'); diff --git a/modules/editor/skins/textarea/editor.html b/modules/editor/skins/textarea/editor.html index 084a80c98..f99c08a5d 100644 --- a/modules/editor/skins/textarea/editor.html +++ b/modules/editor/skins/textarea/editor.html @@ -1,4 +1,7 @@ + + +
@@ -19,17 +22,8 @@ textarea.css("word-wrap", "break-word"); } - // Load existing content - var content_key = textarea.data("editor-content-key-name"); - var content_input = textarea.parents("form").find("input[name='" + content_key + "']"); - if (content_input.size()) { - textarea.val(String(content_input.val()).stripTags().unescape()); - } - - // Save edited content - textarea.on("change", function() { - content_input.val(String($(this).val()).escape()); - }); + // Load + editorTextarea({$editor_sequence}); });
diff --git a/modules/editor/skins/textarea/js/interface.js b/modules/editor/skins/textarea/js/interface.js new file mode 100644 index 000000000..f5d3a91b6 --- /dev/null +++ b/modules/editor/skins/textarea/js/interface.js @@ -0,0 +1,16 @@ +function _getTextareaInstance(editor_sequence) { + return jQuery('#textarea_instance_' + editor_sequence); +} + +function editorGetContent(editor_sequence) { + return _getTextareaInstance(editor_sequence).val().escape(); +} + +function editorReplaceHTML(iframe_obj, content) { + var editor_sequence = parseInt(iframe_obj.id.replace(/^.*_/, ''), 10); + _getTextareaInstance(editor_sequence).val(String(content).stripTags()); +} + +function editorGetIFrame(editor_sequence) { + return _getTextareaInstance(editor_sequence).get(0); +} diff --git a/modules/editor/skins/textarea/js/textarea.js b/modules/editor/skins/textarea/js/textarea.js new file mode 100644 index 000000000..1f624b4a2 --- /dev/null +++ b/modules/editor/skins/textarea/js/textarea.js @@ -0,0 +1,28 @@ +function editorTextarea(editor_sequence) { + var textarea = jQuery("#textarea_instance_" + editor_sequence); + var content_key = textarea.data("editor-content-key-name"); + var primary_key = textarea.data("editor-primary-key-name"); + var insert_form = textarea.closest("form"); + var content_input = insert_form.find("input[name='" + content_key + "']"); + + // Set editor keys + editorRelKeys[editor_sequence] = {}; + editorRelKeys[editor_sequence].primary = insert_form.find("input[name='" + primary_key + "']"); + editorRelKeys[editor_sequence].content = content_input; + editorRelKeys[editor_sequence].func = editorGetContent; + + // Set editor_sequence + insert_form[0].setAttribute('editor_sequence', editor_sequence); + + // Load existing content + if (content_input.size()) { + var content = String(content_input.val()).stripTags(); + content_input.val(content); + textarea.val(content.unescape()); + } + + // Save edited content + textarea.on("change", function() { + content_input.val(String(jQuery(this).val()).escape()); + }); +} \ No newline at end of file From 827be8a2863506c14f5ad86557b1e1e776b37688 Mon Sep 17 00:00:00 2001 From: conory Date: Sat, 15 Jul 2017 23:32:35 +0900 Subject: [PATCH 14/16] =?UTF-8?q?=ED=9A=8C=EC=9B=90=20=EC=84=9C=EB=AA=85?= =?UTF-8?q?=20text=20=EC=86=8C=EA=B8=89=20=EC=A0=81=EC=9A=A9=EC=8B=9C=20?= =?UTF-8?q?=EC=97=AC=EB=9F=AC=EC=A4=84=EC=9D=B4=20=EC=83=9D=EC=84=B1?= =?UTF-8?q?=EB=90=98=EB=8A=94=20=EB=AC=B8=EC=A0=9C=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/member/member.model.php | 1 + 1 file changed, 1 insertion(+) diff --git a/modules/member/member.model.php b/modules/member/member.model.php index ace821b5e..0a3a9070a 100644 --- a/modules/member/member.model.php +++ b/modules/member/member.model.php @@ -1036,6 +1036,7 @@ class memberModel extends member $config = getModel('member')->getMemberConfig(); if($config->signature_html_retroact == 'Y' && $config->signature_html == 'N' && preg_match('/<[^br]+>/i', $signature)) { + $signature = preg_replace('/(\r?\n)+/', "\n", $signature); return getController('member')->putSignature($member_srl, $signature); } From 0437b3797acc9371b78b27dc98c7a813d2d61370 Mon Sep 17 00:00:00 2001 From: conory Date: Sun, 16 Jul 2017 00:15:04 +0900 Subject: [PATCH 15/16] =?UTF-8?q?text=20=EC=BB=A8=EB=B2=84=ED=84=B0?= =?UTF-8?q?=EC=97=90=20trim=20=EA=B3=B5=EB=B0=B1=20=EC=A0=95=EB=A6=AC=20?= =?UTF-8?q?=EA=B3=BC=EC=A0=95=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/editor/editor.model.php | 2 +- modules/member/member.controller.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/editor/editor.model.php b/modules/editor/editor.model.php index c501e8e73..d22017f19 100644 --- a/modules/editor/editor.model.php +++ b/modules/editor/editor.model.php @@ -937,7 +937,7 @@ class editorModel extends editor // To Text if ($converter == 'text') { - $obj->content = escape(strip_tags($obj->content), false); + $obj->content = escape(utf8_trim(strip_tags($obj->content)), false); } // To HTML diff --git a/modules/member/member.controller.php b/modules/member/member.controller.php index 4f7b5b5d9..817c25aa4 100644 --- a/modules/member/member.controller.php +++ b/modules/member/member.controller.php @@ -1618,7 +1618,7 @@ class memberController extends member */ function putSignature($member_srl, $signature) { - if((!$signature = trim(removeHackTag($signature))) || is_empty_html_content($signature)) + if((!$signature = utf8_trim(removeHackTag($signature))) || is_empty_html_content($signature)) { getController('member')->delSignature($member_srl); return; From aecb165532b05e7af7a71521cf639e68a37aedc4 Mon Sep 17 00:00:00 2001 From: conory Date: Sun, 16 Jul 2017 17:12:19 +0900 Subject: [PATCH 16/16] =?UTF-8?q?=EB=A1=9C=EC=A7=81=20=EC=A0=95=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/editor/editor.model.php | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/modules/editor/editor.model.php b/modules/editor/editor.model.php index d22017f19..1c1948e85 100644 --- a/modules/editor/editor.model.php +++ b/modules/editor/editor.model.php @@ -934,14 +934,21 @@ class editorModel extends editor // Convert if ($converter) { - // To Text if ($converter == 'text') { - $obj->content = escape(utf8_trim(strip_tags($obj->content)), false); + // Remove Tag + $obj->content = strip_tags($obj->content); + + // Trim space + $obj->content = utf8_trim($obj->content); + + // Escape + $obj->content = escape($obj->content, false); + + // Insert HTML line + $obj->content = nl2br($obj->content); } - - // To HTML - if ($converter == 'text2html') + elseif ($converter == 'text2html') { $obj->content = Rhymix\Framework\Formatter::text2html($obj->content); }