Skip to content

Commit

Permalink
Validation in api did accept nulls but did not handle them correctly …
Browse files Browse the repository at this point in the history
…in case of trimming input
  • Loading branch information
LorenzoJokhan committed Nov 9, 2023
1 parent ba0fcbc commit 9ab202a
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/models/Idea.js
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ module.exports = function (db, sequelize, DataTypes) {
validate: {
textLength(value) {
// We need to undo the sanitization before we can check the length
let len = htmlToText.fromString(value).length;
let len = htmlToText.fromString(value || '').length;
let summaryMinLength =
(this.config &&
this.config.ideas &&
Expand Down Expand Up @@ -241,7 +241,7 @@ module.exports = function (db, sequelize, DataTypes) {
allowNull: !this.publishDate,
validate: {
textLength(value) {
let len = sanitize.summary(value.trim()).length;
let len = sanitize.summary(value || ''.trim()).length;
let descriptionMinLength =
(this.config &&
this.config.ideas &&
Expand Down

1 comment on commit 9ab202a

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Published new image: openstad/api:bugfix-validation-possibly-operates-on-null-9ab202a

Please sign in to comment.