diff --git a/changelog b/changelog
index eb9c9ab6..7e1d3292 100644
--- a/changelog
+++ b/changelog
@@ -1,3 +1,9 @@
+Fri Sep 27 10:27 2013 CDT
+ * lib/channel.js: Change the link regex, change the way 'affects links'
+ works. The default link filter will only transform a link of no
+ previous filters transform it (and filters will only transform a link
+ if 'affects links' is ticked).
+
Thu Sep 26 23:40 2013 CDT
* lib/config.js: Add config keys for statistics interval & max age,
alias purge interval & max age.
diff --git a/lib/channel.js b/lib/channel.js
index 352d14d5..09745372 100644
--- a/lib/channel.js
+++ b/lib/channel.js
@@ -21,6 +21,7 @@ var Filter = require("./filter.js").Filter;
var Playlist = require("./playlist");
var sanitize = require("validator").sanitize;
var $util = require("./utilities");
+var url = require("url");
var Channel = function(name, Server) {
var self = this;
@@ -1125,7 +1126,7 @@ Channel.prototype.broadcastPoll = function() {
var self = this;
var unhidden = this.poll.packUpdate(true);
var hidden = this.poll.packUpdate(false);
-
+
this.users.forEach(function (u) {
if (self.hasPermission(u, "viewhiddenpoll"))
u.socket.emit("newPoll", unhidden);
@@ -1138,7 +1139,7 @@ Channel.prototype.broadcastPollUpdate = function() {
var self = this;
var unhidden = this.poll.packUpdate(true);
var hidden = this.poll.packUpdate(false);
-
+
this.users.forEach(function (u) {
if (self.hasPermission(u, "viewhiddenpoll"))
u.socket.emit("updatePoll", unhidden);
@@ -2101,17 +2102,25 @@ Channel.prototype.chainMessage = function(user, msg, data) {
}
Channel.prototype.filterMessage = function(msg) {
- const link = /((?:(?:https?)|(?:ftp))(?::\/\/[0-9a-zA-Z\.]+(?::[0-9]+)?[^\s'"$]+))/g;
+ const link = /(\w+:\/\/(?:[^:\/\[\]\s]+|\[[0-9a-f:]+\])(?::\d+)?(?:\/[^\/\s]*)*)/ig;
var subs = msg.split(link);
// Apply other filters
for(var j = 0; j < subs.length; j++) {
if(this.opts.enable_link_regex && subs[j].match(link)) {
- subs[j] = subs[j].replace(link, "$1");
+ var orig = subs[j];
for(var i = 0; i < this.filters.length; i++) {
if(!this.filters[i].filterlinks || !this.filters[i].active)
continue;
subs[j] = this.filters[i].filter(subs[j]);
}
+
+ // only apply link filter if another filter hasn't changed
+ // the link
+ if (subs[j] === orig) {
+ subs[j] = url.format(url.parse(subs[j]));
+ subs[j] = subs[j].replace(link,
+ "$1");
+ }
continue;
}
for(var i = 0; i < this.filters.length; i++) {