Skip to content

Enhancement Request: Add sanitize-html #1233

@100NikhilBro

Description

@100NikhilBro

Enhancement Request: Add sanitize-html

📌 Description

Currently, user inputs (bio, username, query) are stored without sanitization. This can lead to XSS attacks if malicious HTML/JS is submitted. We will use sanitize-html to clean inputs before saving to the database.

🛠 Middleware

  • sanitize-html

🚀 Implementation

  1. Install: npm install sanitize-html
  2. Apply sanitization on text fields:
    
    import sanitizeHtml from "sanitize-html";
    const cleanBio = sanitizeHtml(req.body.bio, {
      allowedTags: [],
      allowedAttributes: {}
    });
        
  3. Use cleaned values before saving in DB.

✅ Expected Outcome

  • Prevent XSS attacks.
  • Only safe and clean text stored in DB.

Metadata

Metadata

Assignees

Type

Projects

Status

done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions