diff --git a/lib/channel.js b/lib/channel.js index a03e07d0..d1fada54 100644 --- a/lib/channel.js +++ b/lib/channel.js @@ -826,7 +826,7 @@ Channel.prototype.handlePendingJoins = function () { }; Channel.prototype.userJoin = function(user, password) { - if (password.length > 100) { + if (typeof password === "string" && password.length > 100) { password = password.substring(0, 100); } var self = this; @@ -1932,6 +1932,10 @@ Channel.prototype.tryOpenPoll = function(user, data) { return; } + for (var i = 0; i < data.opts.length; i++) { + data.opts[i] = ""+data.opts[i]; + } + var obscured = (data.obscured === true); var poll = new Poll(user.name, data.title, data.opts, obscured); this.poll = poll; diff --git a/lib/poll.js b/lib/poll.js index 396e6ae0..af9c6536 100644 --- a/lib/poll.js +++ b/lib/poll.js @@ -8,11 +8,19 @@ The above copyright notice and this permission notice shall be included in all c THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +const link = /(\w+:\/\/(?:[^:\/\[\]\s]+|\[[0-9a-f:]+\])(?::\d+)?(?:\/[^\/\s]*)*)/ig; +var XSS = require("./xss"); var Poll = function(initiator, title, options, obscured) { this.initiator = initiator; - this.title = title; + title = XSS.sanitizeText(title); + this.title = title.replace(link, "$1"); this.options = options; + for (var i = 0; i < this.options.length; i++) { + this.options[i] = XSS.sanitizeText(this.options[i]); + this.options[i] = this.options[i].replace(link, "$1"); + + } this.obscured = obscured || false; this.counts = new Array(options.length); for(var i = 0; i < this.counts.length; i++) { diff --git a/www/assets/js/callbacks.js b/www/assets/js/callbacks.js index 08421e02..4bd7f856 100644 --- a/www/assets/js/callbacks.js +++ b/www/assets/js/callbacks.js @@ -1100,7 +1100,7 @@ Callbacks = { newPoll: function(data) { Callbacks.closePoll(); var pollMsg = $("
").addClass("poll-notify") - .text(data.initiator + " opened a poll: \"" + data.title + "\"") + .html(data.initiator + " opened a poll: \"" + data.title + "\"") .appendTo($("#messagebuffer")); scrollChat(); @@ -1116,7 +1116,7 @@ Callbacks = { }); } - $("

").text(data.title).appendTo(poll); + $("

").html(data.title).appendTo(poll); for(var i = 0; i < data.options.length; i++) { (function(i) { var callback = function () { @@ -1129,7 +1129,7 @@ Callbacks = { $(this).parent().addClass("option-selected"); } $("