내 웹 사이트에는 사용자 생성 콘텐츠가 있습니다. wysiwyg 편집기가 있지만보기 원본 부분이 있습니다. 승인 된 태그가 몇 개 있습니다.div 안의 태그에 div가 영향을 미치지 않도록하려면 어떻게해야합니까?
하지만 사용자가 닫지 않고 그냥 집어 넣으면 어떻게 될까요? 나머지 페이지의 나머지 부분. 어떻게이 문제를 해결할 수 있습니까?
내 웹 사이트에는 사용자 생성 콘텐츠가 있습니다. wysiwyg 편집기가 있지만보기 원본 부분이 있습니다. 승인 된 태그가 몇 개 있습니다.div 안의 태그에 div가 영향을 미치지 않도록하려면 어떻게해야합니까?
하지만 사용자가 닫지 않고 그냥 집어 넣으면 어떻게 될까요? 나머지 페이지의 나머지 부분. 어떻게이 문제를 해결할 수 있습니까?
나는 actaully 당신이 워드 프레스 내가 그것을 테스트이 전까지 어떻게하는지보고 말하고 싶었 그리고 난 개방 된 div하여 쉽고 내가 이걸 발견 어쨌든
을 colosing 나의 페이지를 깰 수 ^^ 걱정하지 않는 워드 프레스를 발견 .
/** * close all open xhtml tags at the end of the string
* * @param string $html
* @return string
* @author Milian <[email protected]>
*/function closetags($html) {
#put all opened tags into an array
preg_match_all('#<([a-z]+)(?: .*)?(?<![/|/ ])>#iU', $html, $result);
$openedtags = $result[1]; #put all closed tags into an array
preg_match_all('#</([a-z]+)>#iU', $html, $result);
$closedtags = $result[1];
$len_opened = count($openedtags);
# all tags are closed
if (count($closedtags) == $len_opened) {
return $html;
}
$openedtags = array_reverse($openedtags);
# close tags
for ($i=0; $i < $len_opened; $i++) {
if (!in_array($openedtags[$i], $closedtags)){
$html .= '</'.$openedtags[$i].'>';
} else {
unset($closedtags[array_search($openedtags[$i], $closedtags)]); }
} return $html;}
이 값은 찾고있는 값이어야합니다.
이것은 매우 복잡한 주제이며 일반적으로 쉬운 바로 가기가 아닙니다. 바퀴의 재발 명을 시작하기 전에 정확하게 작업하도록 설계된 라이브러리를 사용하십시오. 아마도 HTML Purifier은 소수의 도서관 중 하나 일뿐입니다.