How to close unclosed HTML Tags?

后端 未结 8 583
名媛妹妹
名媛妹妹 2020-11-30 01:56

Whenever we are fetching some user inputed content with some editing from the database or similar sources, we might retrieve the portion which only contains the opening tag

8条回答
  •  天命终不由人
    2020-11-30 02:23

    You can use Tidy:

    Tidy is a binding for the Tidy HTML clean and repair utility which allows you to not only clean and otherwise manipulate HTML documents, but also traverse the document tree.

    or HTMLPurifier

    HTML Purifier is a standards-compliant HTML filter library written in PHP. HTML Purifier will not only remove all malicious code (better known as XSS) with a thoroughly audited, secure yet permissive whitelist, it will also make sure your documents are standards compliant, something only achievable with a comprehensive knowledge of W3C's specifications.

提交回复
热议问题