From 0c991b25147d743ee8631ddc5ae3b8aacecf063d Mon Sep 17 00:00:00 2001 From: karmac2015 Date: Tue, 24 Dec 2019 09:26:04 +0200 Subject: [PATCH] Update contacts.js change the regular expression in 'addContact' function to the same regular expression used in 'checkJid' function, to solve the problem of adding contact like the following: 'username@x.x.x.x' (x.x.x.x = IP address). --- src/contacts.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/contacts.js b/src/contacts.js index d5a89f19..c42d2ad6 100755 --- a/src/contacts.js +++ b/src/contacts.js @@ -4363,13 +4363,13 @@ define("xabber-contacts", function () { name = this.$('input[name=contact_name]').removeClass('invalid').val(), groups = this.group_data.get('selected'), contact, error_text, - regexp = /^(([^<>()[\]\\.,;:\s%@\"]+(\.[^<>()[\]\\.,;:\s%@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/; + regexp_full_jid = /^(([^<>()[\]\\.,;:\s%@\"]+(\.[^<>()[\]\\.,;:\s%@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([^<>()[\]\\.,;:\s%@\"]+(\.[^<>()[\]\\.,;:\s%@\"]+)*)|(\".+\"))|(([0-9]{1,3}\.){3}[0-9]{1,3})|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/; jid = Strophe.getBareJidFromJid(jid); if (!jid) { error_text = 'Input username!'; } else if (jid === this.account.get('jid')) { error_text = 'Can not add yourself to contacts!'; - } else if (!regexp.test(jid)) { + } else if (!regexp_full_jid.test(jid)) { error_text = 'Invalid jid'; } else {