Skip to content

Commit

Permalink
trimming composer input before doing length check in replies
Browse files Browse the repository at this point in the history
  • Loading branch information
julianlam committed Nov 21, 2016
1 parent ef6d52c commit 576df84
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/topics/create.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

var async = require('async');
var validator = require('validator');
var S = require('string');
var db = require('../database');
var utils = require('../../public/src/utils');
var plugins = require('../plugins');
Expand Down Expand Up @@ -327,6 +328,9 @@ module.exports = function (Topics) {
}

function check(item, min, max, minError, maxError, callback) {
// Trim and remove HTML (latter for composers that send in HTML, like redactor)
item = S(item.trim()).stripTags().s;

if (!item || item.length < parseInt(min, 10)) {
return callback(new Error('[[error:' + minError + ', ' + min + ']]'));
} else if (item.length > parseInt(max, 10)) {
Expand Down

1 comment on commit 576df84

@pauljherring
Copy link

Choose a reason for hiding this comment

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

A single post of

<img src="http://example.com/hello.jpg" />

would appear to not fit the criteria of not having more than 2 characters..

(ref: https://what.thedailywtf.com/topic/21646/count-the-characters)

Please sign in to comment.