mirror of
https://github.com/thelounge/thelounge
synced 2024-11-10 22:54:15 +00:00
Merge pull request #2858 from thelounge/xpaw/limit-nick
Hard limit nicks to 100 characters, add maxlength on connect inputs
This commit is contained in:
commit
5b40a6fb58
3 changed files with 19 additions and 6 deletions
|
@ -29,13 +29,13 @@
|
|||
<label for="connect:name">Name</label>
|
||||
</div>
|
||||
<div class="col-sm-9">
|
||||
<input class="input" id="connect:name" name="name" value="{{defaults.name}}">
|
||||
<input class="input" id="connect:name" name="name" value="{{defaults.name}}" maxlength="100">
|
||||
</div>
|
||||
<div class="col-sm-3">
|
||||
<label for="connect:host">Server</label>
|
||||
</div>
|
||||
<div class="col-sm-6 col-xs-8">
|
||||
<input class="input" id="connect:host" name="host" value="{{defaults.host}}" aria-label="Server address" required {{#if lockNetwork}}disabled{{/if}}>
|
||||
<input class="input" id="connect:host" name="host" value="{{defaults.host}}" aria-label="Server address" maxlength="255" required {{#if lockNetwork}}disabled{{/if}}>
|
||||
</div>
|
||||
<div class="col-sm-3 col-xs-4">
|
||||
<div class="port">
|
||||
|
@ -65,28 +65,28 @@
|
|||
<label for="connect:nick">Nick</label>
|
||||
</div>
|
||||
<div class="col-sm-9">
|
||||
<input class="input nick" id="connect:nick" name="nick" value="{{defaults.nick}}" required>
|
||||
<input class="input nick" id="connect:nick" name="nick" value="{{defaults.nick}}" maxlength="100" required>
|
||||
</div>
|
||||
{{#unless useHexIp}}
|
||||
<div class="col-sm-3">
|
||||
<label for="connect:username">Username</label>
|
||||
</div>
|
||||
<div class="col-sm-9">
|
||||
<input class="input username" id="connect:username" name="username" value="{{defaults.username}}">
|
||||
<input class="input username" id="connect:username" name="username" value="{{defaults.username}}" maxlength="512">
|
||||
</div>
|
||||
{{/unless}}
|
||||
<div class="col-sm-3">
|
||||
<label for="connect:password">Password</label>
|
||||
</div>
|
||||
<div class="col-sm-9 password-container">
|
||||
<input class="input" id="connect:password" type="password" name="password" value="{{defaults.password}}">
|
||||
<input class="input" id="connect:password" type="password" name="password" value="{{defaults.password}}" maxlength="512">
|
||||
{{> ../reveal-password}}
|
||||
</div>
|
||||
<div class="col-sm-3">
|
||||
<label for="connect:realname">Real name</label>
|
||||
</div>
|
||||
<div class="col-sm-9">
|
||||
<input class="input" id="connect:realname" name="realname" value="{{defaults.realname}}">
|
||||
<input class="input" id="connect:realname" name="realname" value="{{defaults.realname}}" maxlength="512">
|
||||
</div>
|
||||
{{#if defaults.uuid}}
|
||||
<div class="col-sm-3">
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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) {
|
||||
|
|
Loading…
Reference in a new issue