우리가 에디터의 html 모드에서 태그를 작성하다 보면 차단된 태그는 입력을 해도 본문에서는 나타나지 않습니다. 대표적인 예가 audio, video 태그인데 그에 대한 hook 파일은 이미 플러그인으로 공유한 바 있습니다.
https://sir.kr/g5_plugin/11459
여기에 새로운 태그를 화이트리스트로 추가를 하고 싶습니다. 예를 들어서
아래와 같은 input 태그를 사용하면 본문에서는 먹빡이죠.
<input type="checkbox" id="me" name="me" value="비타주리" checked>
이런 것들을 개별적으로 허용하는 방법입니다. 가장 마지막에 제가 어떤 코드를 보탰는지 살펴보고 이와 같은 패턴으로 다른 것들도 적용해 주면 되겠습니다.
[code]
<?php if (!defined('_GNUBOARD_')) exit;
add_event('html_purifier_config', function($config) {
$add_html_tag = $config -> getHTMLDefinition(1);
$add_html_tag -> addElement('iframe', 'Block', 'Flow', 'Common', ['allow' => 'Text', 'allowfullscreen' => 'Bool']);
$add_html_tag -> addElement('video', 'Block', 'Flow', 'Common', ['src' => 'Text', 'autoplay' => 'Bool', 'loop' => 'Bool', 'controls' => 'Bool', 'muted' => 'Bool', 'controlslist' => 'Text']);
$add_html_tag -> addElement('audio', 'Block', 'Flow', 'Common', ['src' => 'Text', 'autoplay' => 'Bool', 'loop' => 'Bool', 'controls' => 'Bool', 'muted' => 'Bool', 'controlslist' => 'Text']);
$add_html_tag -> addElement('input', 'Block', 'Flow', 'Common', ['type' => 'Text', 'id' => 'Text', 'name' => 'Text', 'value' => 'Text', 'checked' => 'Bool']);
}, 1, 1);
[/code]
$add_html_tag -> addElement('input', 'Block', 'Flow', 'Common', ['type' => 'Text', 'id' => 'Text', 'name' => 'Text', 'value' => 'Text', 'checked' => 'Bool']);
속성의 형태는 여러가지를 테스해 본 결과 Text 와 Bool 이 2가지면 족합니다.
전자는 문자형이고 후자는 불린형입니다.
그리고 width 나 height 역시 Text 로 추가해주면 되지만 그냥 style 로 주는 것이 더 간명합니다.
참고로 이것은 그누 55832 이상부터 사용 가능합니다.
댓글 8개
감사합니다
혹시 아래와 같은 폼값도 넣을 수 있나요?
<form name="Ins_from" id="form1" action='https://naver.com/pr_t.php' method="post" onsubmit="return fvalchk(this);" target=hiddenframe>
<INPUT type=hidden value="<?= $partner_id ?>" name=partner_id>
<INPUT type=hidden name=item_no value="444">
<div style="width:100%; max-width:580px; margin:0 auto;">
<input type="hidden" name="prc" value="write">
<table width="100%" border="0" cellpadding="0" cellspacing="0" align="center" id="designForm">
<tr>
<th bgcolor="#f0f0f0" width="30%" class="th00">* <b>이름</b></th>
<td bgcolor="#ffffff" align="center" width="70%" class="td00"><input type="text" name="user_name" alt="이름" title="이름" itemname="이름" required class="mb_long_text" placeholder="필수 입력 사항 입니다."></td>
</tr>
<tr>
<th bgcolor="#f0f0f0" width="30%" class="th01">* <b>나이</b></th>
<td bgcolor="#ffffff" align="center" width="70%" class="td01"><input type="tel" name="나이" alt="나이" title="나이" itemname="나이" required class="mb_long_text" placeholder="필수 입력 사항 입니다."></td>
</tr>
</table>
</form>
게시글 목록
| 번호 | 제목 |
|---|---|
| 22041 | |
| 22035 | |
| 22033 | |
| 22028 | |
| 22019 | |
| 22006 | |
| 22005 | |
| 21995 | |
| 21989 | |
| 21978 | |
| 21972 | |
| 21961 | |
| 21956 | |
| 21944 | |
| 21934 | |
| 21932 | |
| 21924 | |
| 21922 | |
| 21921 | |
| 21910 | |
| 21908 | |
| 21897 | |
| 21883 | |
| 21881 | |
| 21875 | |
| 21854 | |
| 21852 | |
| 21851 | |
| 21829 | |
| 21817 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기