Skip to content

Commit

Permalink
feat: add select, textarea and img to the list of allowed tags
Browse files Browse the repository at this point in the history
  • Loading branch information
lucgagan committed Nov 12, 2023
1 parent e90d1fb commit aead59f
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/sanitizeHtml.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,19 @@
import sanitize from "sanitize-html";

/**
* The reason for sanitization is because we do not need all HTML tags to be present in the prompt.
* For example, we do not need <style> or <script> tags to be present in the prompt.
* In my experience, reducing HTML only to basic tags produces faster and more reliable prompts.
*/
export const sanitizeHtml = (subject: string) => {
return sanitize(subject, {
allowedTags: sanitize.defaults.allowedTags.concat([
"button",
"form",
"img",
"input",
"button",
"select",
"textarea",
]),
allowedAttributes: false,
});
Expand Down

0 comments on commit aead59f

Please sign in to comment.