mirror of
https://github.com/inverse-inc/sogo.git
synced 2026-10-19 18:18:12 +00:00
fix(web(js)): improve validation of email addresses
Overwrite the AngularJS validation and transformation of email inputs in order to support umlauts and eszett.
This commit is contained in:
1 parent
5e6ad77d4c
commit
67ccf748ed
9 files changed
+32
-22
No files matched your search
@@ -199,7 +199,8 @@
|
|||||||
<label>
|
<label>
|
||||||
<var:string label:value="Email Address"/>
|
<var:string label:value="Email Address"/>
|
||||||
</label>
|
</label>
|
||||||
<input type="email" ng-model="email.value"
|
<input type="text" ng-model="email.value"
|
||||||
|
ng-pattern="editor.emailRE"
|
||||||
sg-focus-on="email_{{$index}}"/>
|
sg-focus-on="email_{{$index}}"/>
|
||||||
</md-input-container>
|
</md-input-container>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -164,9 +164,10 @@
|
|||||||
<md-input-container class="md-block"
|
<md-input-container class="md-block"
|
||||||
ng-hide="$AccountDialogController.customFromIsReadonly()">
|
ng-hide="$AccountDialogController.customFromIsReadonly()">
|
||||||
<label><var:string label:value="Reply To Email"/></label>
|
<label><var:string label:value="Reply To Email"/></label>
|
||||||
<input type="email"
|
<input type="text"
|
||||||
autocomplete="off"
|
autocomplete="off"
|
||||||
ng-model="identity.replyTo"/>
|
ng-model="identity.replyTo"
|
||||||
|
ng-pattern="$AccountDialogController.emailRE"/>
|
||||||
</md-input-container>
|
</md-input-container>
|
||||||
<md-input-container
|
<md-input-container
|
||||||
class="md-block md-flex"
|
class="md-block md-flex"
|
||||||
|
|||||||
@@ -79,9 +79,10 @@
|
|||||||
<var:string label:value="When I modify my calendar, send a mail to"/>
|
<var:string label:value="When I modify my calendar, send a mail to"/>
|
||||||
</md-checkbox>
|
</md-checkbox>
|
||||||
<md-input-container flex-offset="5" md-no-float="md-no-float">
|
<md-input-container flex-offset="5" md-no-float="md-no-float">
|
||||||
<input type="email"
|
<input type="text"
|
||||||
label:placeholder="Email Address"
|
label:placeholder="Email Address"
|
||||||
ng-model="properties.calendar.notifiedUserOnPersonalModifications"
|
ng-model="properties.calendar.notifiedUserOnPersonalModifications"
|
||||||
|
ng-pattern="properties.emailRE"
|
||||||
ng-required="properties.calendar.notifications.notifyUserOnPersonalModifications"
|
ng-required="properties.calendar.notifications.notifyUserOnPersonalModifications"
|
||||||
ng-disabled="!properties.calendar.notifications.notifyUserOnPersonalModifications"/>
|
ng-disabled="!properties.calendar.notifications.notifyUserOnPersonalModifications"/>
|
||||||
</md-input-container>
|
</md-input-container>
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
/* -*- Mode: javascript; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
/* -*- Mode: javascript; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||||
|
|
||||||
|
String.emailRE = /([\w\!\#$\%\&\'\*\+\-\/\=\?\^\`{\|\}\~]+\.)*[\w\!\#$\%\&\'\*\+\-\/\=\?\^\`{\|\}\~]+@((((([\u00C0-\u017Fa-z0-9]{1}[\u00C0-\u017Fa-z0-9\-]{0,62}[\u00C0-\u017Fa-z0-9]{1})|[\u00C0-\u017Fa-z])\.)+[a-z]{2,})|(\d{1,3}\.){3}\d{1,3}(\:\d{1,5})?)/;
|
||||||
|
|
||||||
String.prototype.endsWith = function(suffix) {
|
String.prototype.endsWith = function(suffix) {
|
||||||
return this.indexOf(suffix, this.length - suffix.length) !== -1;
|
return this.indexOf(suffix, this.length - suffix.length) !== -1;
|
||||||
};
|
};
|
||||||
@@ -135,10 +137,13 @@ String.prototype.formatted = function() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
String.prototype.isValidEmail = function(strict) {
|
String.prototype.isValidEmail = function(strict) {
|
||||||
var emailRE = strict ?
|
var result = emailRE.test(this);
|
||||||
/^([\w\!\#$\%\&\'\*\+\-\/\=\?\^\`{\|\}\~]+\.)*[\w\!\#$\%\&\'\*\+\-\/\=\?\^\`{\|\}\~]+@((((([a-z0-9]{1}[a-z0-9\-]{0,62}[a-z0-9]{1})|[a-z])\.)+[a-z]{2,})|(\d{1,3}\.){3}\d{1,3}(\:\d{1,5})?)$/i : /([\w\!\#$\%\&\'\*\+\-\/\=\?\^\`{\|\}\~]+\.)*[\w\!\#$\%\&\'\*\+\-\/\=\?\^\`{\|\}\~]+@((((([a-z0-9]{1}[a-z0-9\-]{0,62}[a-z0-9]{1})|[a-z])\.)+[a-z]{2,})|(\d{1,3}\.){3}\d{1,3}(\:\d{1,5})?)/i;
|
|
||||||
|
|
||||||
return emailRE.test(this);
|
if (strict && result) {
|
||||||
|
result = emailRE.exec(this)[0] == this;
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
};
|
};
|
||||||
|
|
||||||
String.prototype.asCSSIdentifier = function() {
|
String.prototype.asCSSIdentifier = function() {
|
||||||
|
|||||||
@@ -11,16 +11,17 @@
|
|||||||
function CardController($scope, $timeout, $window, $mdDialog, sgSettings, AddressBook, Card, Dialog, sgHotkeys, focus, $state, $stateParams, stateCard) {
|
function CardController($scope, $timeout, $window, $mdDialog, sgSettings, AddressBook, Card, Dialog, sgHotkeys, focus, $state, $stateParams, stateCard) {
|
||||||
var vm = this, hotkeys = [];
|
var vm = this, hotkeys = [];
|
||||||
|
|
||||||
vm.card = stateCard;
|
this.card = stateCard;
|
||||||
|
|
||||||
vm.currentFolder = AddressBook.selectedFolder;
|
this.currentFolder = AddressBook.selectedFolder;
|
||||||
vm.allEmailTypes = Card.$EMAIL_TYPES;
|
this.allEmailTypes = Card.$EMAIL_TYPES;
|
||||||
vm.allTelTypes = Card.$TEL_TYPES;
|
this.allTelTypes = Card.$TEL_TYPES;
|
||||||
vm.allUrlTypes = Card.$URL_TYPES;
|
this.allUrlTypes = Card.$URL_TYPES;
|
||||||
vm.allAddressTypes = Card.$ADDRESS_TYPES;
|
this.allAddressTypes = Card.$ADDRESS_TYPES;
|
||||||
vm.categories = {};
|
this.categories = {};
|
||||||
vm.userFilterResults = [];
|
this.userFilterResults = [];
|
||||||
vm.showRawSource = false;
|
this.showRawSource = false;
|
||||||
|
this.emailRE = String.emailRE;
|
||||||
|
|
||||||
|
|
||||||
_registerHotkeys(hotkeys);
|
_registerHotkeys(hotkeys);
|
||||||
|
|||||||
@@ -279,7 +279,7 @@
|
|||||||
if (angular.isString(this[type])) {
|
if (angular.isString(this[type])) {
|
||||||
// The recipient is a string; try to extract the name
|
// The recipient is a string; try to extract the name
|
||||||
var emailRE = /<?(([\w\!\#$\%\&\'\*\+\-\/\=\?\^\`{\|\}\~]+\.)*[\w\!\#$\%\&\'\*\+\-\/\=\?\^\`{\|\}\~]+@((((([a-z0-9]{1}[a-z0-9\-]{0,62}[a-z0-9]{1})|[a-z])\.)+[a-z]{2,})|(\d{1,3}\.){3}\d{1,3}(\:\d{1,5})?))/i;
|
var emailRE = /<?(([\w\!\#$\%\&\'\*\+\-\/\=\?\^\`{\|\}\~]+\.)*[\w\!\#$\%\&\'\*\+\-\/\=\?\^\`{\|\}\~]+@((((([a-z0-9]{1}[a-z0-9\-]{0,62}[a-z0-9]{1})|[a-z])\.)+[a-z]{2,})|(\d{1,3}\.){3}\d{1,3}(\:\d{1,5})?))/i;
|
||||||
var match = this[type].match(emailRE);
|
var match = this[type].match(String.emailRE);
|
||||||
if (match) {
|
if (match) {
|
||||||
address = this[type].substring(0, match.index);
|
address = this[type].substring(0, match.index);
|
||||||
address = address.replace(/^\"? *(.+?)\"? *$/, "$1");
|
address = address.replace(/^\"? *(.+?)\"? *$/, "$1");
|
||||||
|
|||||||
@@ -16,6 +16,7 @@
|
|||||||
this.account = account;
|
this.account = account;
|
||||||
this.accountId = accountId;
|
this.accountId = accountId;
|
||||||
this.hostnameRE = usesSSO && accountId > 0 ? /^(?!(127\.0\.0\.1|localhost(?:\.localdomain)?)$)/ : /./;
|
this.hostnameRE = usesSSO && accountId > 0 ? /^(?!(127\.0\.0\.1|localhost(?:\.localdomain)?)$)/ : /./;
|
||||||
|
this.emailRE = String.emailRE;
|
||||||
this.addressesSearchText = '';
|
this.addressesSearchText = '';
|
||||||
this.ckConfig = {
|
this.ckConfig = {
|
||||||
'autoGrow_minHeight': 70,
|
'autoGrow_minHeight': 70,
|
||||||
|
|||||||
@@ -294,12 +294,11 @@
|
|||||||
destinationCalendar = Calendar.$get(this.component.destinationCalendar),
|
destinationCalendar = Calendar.$get(this.component.destinationCalendar),
|
||||||
options = initOrganizer? { organizerCalendar: destinationCalendar } : {},
|
options = initOrganizer? { organizerCalendar: destinationCalendar } : {},
|
||||||
promises = [];
|
promises = [];
|
||||||
var emailRE = /([\w\!\#$\%\&\'\*\+\-\/\=\?\^\`{\|\}\~]+\.)*[\w\!\#$\%\&\'\*\+\-\/\=\?\^\`{\|\}\~]+@((((([a-z0-9]{1}[a-z0-9\-]{0,62}[a-z0-9]{1})|[a-z])\.)+[a-z]{2,})|(\d{1,3}\.){3}\d{1,3}(\:\d{1,5})?)/i,
|
var i, address;
|
||||||
i, address;
|
|
||||||
if (partial) options.partial = partial;
|
if (partial) options.partial = partial;
|
||||||
|
|
||||||
function createCard(str) {
|
function createCard(str) {
|
||||||
var match = str.match(emailRE),
|
var match = str.match(String.emailRE),
|
||||||
email = match[0],
|
email = match[0],
|
||||||
name = str.replace(new RegExp(" *<?" + email + ">? *"), '');
|
name = str.replace(new RegExp(" *<?" + email + ">? *"), '');
|
||||||
vm.showAttendeesEditor |= initOrganizer;
|
vm.showAttendeesEditor |= initOrganizer;
|
||||||
@@ -333,7 +332,7 @@
|
|||||||
card.charCodeAt(i) == 32 || // space
|
card.charCodeAt(i) == 32 || // space
|
||||||
card.charCodeAt(i) == 44 || // ,
|
card.charCodeAt(i) == 44 || // ,
|
||||||
card.charCodeAt(i) == 59) && // ;
|
card.charCodeAt(i) == 59) && // ;
|
||||||
emailRE.test(address)) {
|
String.emailRE.test(address)) {
|
||||||
promises.push(createCard(address).then(addCard));
|
promises.push(createCard(address).then(addCard));
|
||||||
address = '';
|
address = '';
|
||||||
}
|
}
|
||||||
@@ -341,7 +340,7 @@
|
|||||||
address += card.charAt(i);
|
address += card.charAt(i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (address && emailRE.test(address)) {
|
if (address && String.emailRE.test(address)) {
|
||||||
promises.push(createCard(address).then(addCard));
|
promises.push(createCard(address).then(addCard));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -245,6 +245,7 @@
|
|||||||
function PropertiesDialogController($scope, $mdDialog, srcCalendar) {
|
function PropertiesDialogController($scope, $mdDialog, srcCalendar) {
|
||||||
var vm = this;
|
var vm = this;
|
||||||
|
|
||||||
|
vm.emailRE = String.emailRE;
|
||||||
vm.calendar = new Calendar(srcCalendar.$omit());
|
vm.calendar = new Calendar(srcCalendar.$omit());
|
||||||
vm.saveProperties = saveProperties;
|
vm.saveProperties = saveProperties;
|
||||||
vm.close = close;
|
vm.close = close;
|
||||||
|
|||||||
Reference in new issue
Block a user