2013-02-03 7 views
0

javascript 텍스트 편집기로 작성된 html 텍스트 입력을 내 데이터베이스에 저장하는 것이 안전하고 일반적인 방법입니까?레일 HTML 형식의 서식있는 텍스트 편집기로 작성된 텍스트 본문 저장

사용자가 응용 프로그램에서 기사를 입력하기 위해 ckeditor를 사용한다고 가정합니다. 기사는 클라이언트 측에서 볼 때 멋지게 보이지만 데이터베이스에서 쿼리하면 기사가 너무 복잡합니다.

예를 들어, 텍스트 본문은 다음과 같이 저장됩니다 :

<p class="MsoListParagraph" style="margin-left:56.0pt;mso-para-margin-left:0gd; 
text-indent:-18.0pt;mso-list:l3 level1 lfo1"><!--[if !supportLists]--><span lang="EN-US" style="font-size: 12pt; font-family: 'Times New Roman';">-<span style="font-size: 12pt; line-height: normal;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
</span></span><!--[endif]--><span lang="EN-US" style="font-size: 12pt; font-family: 'Times New Roman';">Natural selection is a process that individuals 
have some heritable characteristics to survive and reproduce at a higher rate 
compare to other individuals. Natural selection increases the match between 
organisms and environments. Furthermore, as an environment changes or 
individuals move to a new place, natural selection may effect of adaptation to 
these new conditions by giving rise to new species in the process. Natural 
selection can only increase or decrease heritable traits.&nbsp; <u><o:p></o:p></u></span></p> 

몸은

이 문제를 처리 할 수있는 더 나은 방법이 있나요 @article.body.html_safe 같은 렌더링?

답변

0

데이터베이스가 텍스트의 내부를 알아야 할 필요가없는 경우,이를 효과적으로 저장하여 불투명 한 얼룩으로 효과적으로 처리 할 수 ​​있습니다.

누군가가 항목을 볼 때 더 큰 문제는 웹 브라우저의 보안입니다. 다른 사람이 문서에 자바 스크립트 비트를 저장할 수 있기 때문에 입력을 확인하기 위해 신중해야합니다. 그런 다음 자바 스크립트는 해당 기사를 보는 사람의 브라우저에서 실행됩니다.

여기에있는 답변과 같은 답변을 참조하십시오. filtering tags