package:sanitize_html - Added containsDisallowedContent Function for Detecting Prohibited HTML in User-Defined Validation Scenarios#263
Conversation
…r-defined validation
|
At the moment this package is aimed at aligning with github gfm sanitization rules: Arguably, these have changed, I don't think github uses that code anymore. But I'm hesitant to just add features. If there is a lot of community members that would rather have an HTML sanitation package with more advanced features I'm inclined to suggest that you write such a package, publish and maintain it yourself. Feel free to fork this package and give it a new better name, ideally collaborate with others. Honestly, I'd be more than happy for On topic of this PR, I might get around to doing a review, but again, I'm hesitant to accept more features. Maybe, if it turns out we need them elsewhere too. |
Hi @jonasfj, Thanks for the feedback! Of course, I’ll see if I can manage to create a new package with more advanced features. I also appreciate the suggestion—it’s definitely going to take a lot of time to make a high-quality package 😁 |
Motivation:
In scenarios where users only want to detect malicious or disallowed HTML content without sanitizing it, a validation mechanism becomes crucial. This feature allows applications to abort processes or take corrective actions when encountering unsafe HTML, ensuring robustness and security.
Use Cases:
Prevent Malicious Submissions:
Detect malicious content in user-generated inputs, such as comment fields or form submissions, and reject the input early without modifying the HTML.
Abort Application Flow:
Halt the execution of specific workflows (e.g., data processing or rendering) if unsafe HTML is detected, ensuring that the application does not proceed with invalid data.
Custom Security Workflows:
Integrate with security pipelines to log, monitor, or analyze the occurrence of unsafe HTML without sanitizing or altering the input.
Audit User Content:
Validate HTML against custom policies for compliance audits without altering the original content, useful for applications dealing with regulatory constraints or collaborative platforms.
Summary of Changes:
containsDisallowedContent, a validation function to detect prohibited HTML tags, attributes, or links.id,class, and attribute handling.This feature extends the library's utility by providing a lightweight, focused mechanism for HTML validation.