Skip to content

Commit

Permalink
Fix validation.
Browse files Browse the repository at this point in the history
  • Loading branch information
Skorpios604 committed Jan 19, 2025
1 parent c9147f7 commit 3575465
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions Server/db/models/Notification.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,14 @@ const NotificationSchema = mongoose.Schema(
type: String,
validate: {
validator: function(v) {
return !this.type ||
this.type !== 'apprise' ||
/^[a-zA-Z]+:\/\//.test(v);
if (this.type !== 'apprise') return true;
if (!v || v.length > 2048) return false;

// Apprise URL format: scheme://[user:pass@]host[:port]/path
const appriseUrlRegex = /^[a-zA-Z]+:\/\/([^:\s]+:[^@\s]+@)?[^\s\/:]+(:\d+)?(\/[^\s]*)?$/;
return appriseUrlRegex.test(v);
},
message: 'Invalid Apprise URL format'
message: 'Invalid Apprise URL: Must be a valid service URL under 2048 characters'
}
},
address: {
Expand Down

0 comments on commit 3575465

Please sign in to comment.