diff --git a/src/models/network.js b/src/models/network.js
index 0bf59524..28edc340 100644
--- a/src/models/network.js
+++ b/src/models/network.js
@@ -64,6 +64,11 @@ function Network(attr) {
}
Network.prototype.validate = function(client) {
+ // If entered nick is over 100 characters, limit it so we don't try to compile a big regex
+ if (this.nick && this.nick.length > 100) {
+ this.nick = this.nick.substring(0, 100);
+ }
+
this.setNick(String(this.nick || Helper.getDefaultNick()).replace(" ", "_"));
if (!this.username) {
diff --git a/src/plugins/inputs/nick.js b/src/plugins/inputs/nick.js
index a0a486ed..ecff77ae 100644
--- a/src/plugins/inputs/nick.js
+++ b/src/plugins/inputs/nick.js
@@ -24,6 +24,14 @@ exports.input = function(network, chan, cmd, args) {
const newNick = args[0];
+ if (newNick.length > 100) {
+ chan.pushMessage(this, new Msg({
+ type: Msg.Type.ERROR,
+ text: "Nicknames may not be this long.",
+ }));
+ return;
+ }
+
// If connected to IRC, send to server and wait for ACK
// otherwise update the nick and UI straight away
if (network.irc && network.irc.connection) {