Highlighted code in a post are affecting my website

152 Views Asked by At

i am using my WMD editor to as markup editor and google prettify to highlight syntax marked by WMD editor,i am using yii as a framework and whenever i include some html in my code,in stead of being highlighted they are being interpreted as part of the my main html page and break down the structure of the web,i think this is because i used the yii method of decoding what will be displayed in stead of encode but again if i use the encode method..the posted syntax is treated as a string,therefore can not be highlighted,any help will be appreciated

   <div class="question-user-time" style="float:center;"><span class="question-owner"><?php echo "posted by ".$qowner->username." on ".$model->create_date;?> </span></div>
    </div>
    <div><?php echo html_entity_decode($model->content);?></div>

Thanks you very much

here is how the website is brokenenter image description here

1

There are 1 best solutions below

5
On

You have to be very careful when generating web pages that all the elements are properly encoded, quoted and escaped. It can be a very complex problem. Just as a trivial example, suppose you have a character string in the database which contains the character '>'. If you simply spit it out to fill in a blank in some boilerplate text, you'll turn your entire web page into hash because the '>' is treated as a html element.