What kind of mechanism does blog softwares like wordpress deal with the html inside a entry content?
What kind of mechanism does blog softwares like wordpress deal with the html inside a entry content?
I want to know:
- How does it display pictures and links in a blog entry? Is the content of a blog entry in HTML?
- When it displays entry list on the index page, how does it make a summary/digest of each entry without breaking开发者_Python百科 the HTML tags inside the summary/digest? Because if I only get first few character in a blog entry content/summary, there will be possibilities to break some tags, leaving only the open tag. For example:
Hello world!<h1> Hello worl...
- How does it escape dangerous tags/scripts inside the HTML of blog entries?
How does it display pictures and links in a blog entry? Is the content of a blog entry in HTML?
Yes. Plain old HTML.
When it displays entry list on the index page, how does it make a summary/digest of each entry without breaking the HTML tags inside the summary/digest?
Typically it will run through text through a PHP function (strip_tags() ) that strips out the HTML tags and just leaves the text behind. Alternately/Additionally you can enter an excerpt for any post and use the_excerpt() function to return just that. Excerpts have tags stripped by default.
How does it escape dangerous tags/scripts inside the HTML of blog entries?
WordPress has built in functions to sanitize data and those fire automatically on $wpdb->insert and $wpdb->update. For much more information and detail, read the WP Codex entry for this.
精彩评论