How do I use the BBCode code? And how is it safe to use?

Source: Internet
Author: User
Tags bbcode
I think it should be like this:
1 receive the text with BBCode.
2 text with BBCode is stored directly in the database.
----3.1 If you want to display, use a function that converts text with BBCode to HTML.
----3.2 If you want to edit, display the text with BBCode directly.

The main security aspect is to block HTML tags. How should this be blocked? is to add htmlspecialchars () directly at the first step of receiving it? Does this interfere with the function of converting text with BBCode to HTML?
There is also the NL2BR () function. What should be the order of use of the three functions mentioned earlier?

Is there any other place you need to be aware of?


Reply to discussion (solution)

Save As-is
BBCode decoding after htmlspecialchars of saved text is displayed

Save As-is
BBCode decoding after htmlspecialchars of saved text is displayed
NL2BR () 's location? When receiving, use textarea.

You may need to use NL2BR () only when displaying
To use, also after BBCode decoding

  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.