Skip to content

Commit

Permalink
Merge pull request #762 from openstad/hotfix/resource-form-trim-descr…
Browse files Browse the repository at this point in the history
…iption

fix: Sanitize emoji's as the database doesn't accept it
  • Loading branch information
iandebruin98 authored Feb 18, 2025
2 parents 7003309 + 3f18015 commit 85cc182
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion apps/api-server/src/util/sanitize.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
var sanitize = require('sanitize-html');

const removeEmojis = (text) => {
return text.replace(/\p{Emoji}/gu, '');
};

// Decorator for the sanitize function
// This prevents the bug where sanitize returns the string 'null' when null is passed
const sanitizeIfNotNull = (text, tags) => {
if (text === null) {
return null;
}

text = removeEmojis(text);
return sanitize(text, tags);
}

Expand Down

0 comments on commit 85cc182

Please sign in to comment.