|
@@ -139,6 +139,28 @@ io.on('connection', (socket) => {
|
|
|
|
|
|
socket.on('message', (msg) => {
|
|
|
if (msg) {
|
|
|
+ if (!user.admin) {
|
|
|
+ const regex = /( |<([^>]+)>)/ig;
|
|
|
+ msg = msg.replace(regex, "");
|
|
|
+ }
|
|
|
+
|
|
|
+ msg = msg.replace(/(?<!href=")(\b[\w]+:\/\/[\w-?&;#~=\.\/\@%]+[\w\/])/g, (url) => {
|
|
|
+ if (url.toLowerCase().endsWith('.jpg')
|
|
|
+ || url.toLowerCase().endsWith('.gif')
|
|
|
+ || url.toLowerCase().endsWith('.png')) {
|
|
|
+ return '<a href="' + url + '"><img src="' + url + '" alt="" /></a>';
|
|
|
+ }
|
|
|
+
|
|
|
+ var faviconUrl;
|
|
|
+ try {
|
|
|
+ faviconUrl = new URL(url).origin + '/favicon.ico';
|
|
|
+ } catch (e) {
|
|
|
+ log('Error getting favicon for "' + url + '"');
|
|
|
+ }
|
|
|
+
|
|
|
+ return '<a href="' + url + '"><img class="favicon" src="' + faviconUrl + '" alt="" />' + url + '</a>';
|
|
|
+ });
|
|
|
+
|
|
|
log(user.name + ':', msg, '(' + user.ip + ')');
|
|
|
if (history.length >= HISTORY_SIZE) {
|
|
|
history = history.slice(1);
|