mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-12-22 14:41:29 +01:00
Fix handling of email addresses with names
- read-only was leaving out quotes on name, failing validation - Commas in name caused problems when adding in to existing values due to simplistic CSV splitting
This commit is contained in:
parent
6417aa8777
commit
7a17dcc7cb
@ -11,7 +11,6 @@
|
||||
import {IsEmail} from "../Validators/IsEmail";
|
||||
import {Et2UrlEmail} from "./Et2UrlEmail";
|
||||
import {Et2UrlReadonly} from "./Et2UrlReadonly";
|
||||
import {Et2EmailTag} from "../Et2Select/Tag/Et2EmailTag";
|
||||
|
||||
/**
|
||||
* @customElement et2-url-email_ro
|
||||
@ -89,7 +88,7 @@ export class Et2UrlEmailReadonly extends Et2UrlReadonly
|
||||
{
|
||||
let email;
|
||||
if (IsEmail.EMAIL_PREG.exec(email=this.value) ||
|
||||
IsEmail.EMAIL_PREG.exec(email=this.value+' <'+this.statustext+'>'))
|
||||
IsEmail.EMAIL_PREG.exec(email = '"' + this.value + '" <' + this.statustext + '>'))
|
||||
{
|
||||
Et2UrlEmail.action(email);
|
||||
}
|
||||
|
@ -57,6 +57,17 @@ egw.extend('open', egw.MODULE_WND_LOCAL, function(_egw, _wnd)
|
||||
bcc: match['bcc'] || []
|
||||
};
|
||||
|
||||
// No CSV, split them here and pay attention to quoted commas
|
||||
const split_regex = /("[^"]*" <[^>]*>)|("[^"]*")|('[^']*')|([^,]+)/g;
|
||||
for (let index in content)
|
||||
{
|
||||
if (typeof content[index] == "string")
|
||||
{
|
||||
const matches = content[index].match(split_regex);
|
||||
content[index] = matches ?? content[index];
|
||||
}
|
||||
}
|
||||
|
||||
// Encode html entities in the URI, otheerwise server XSS protection wont
|
||||
// allow it to pass, because it may get mistaken for some forbiden tags,
|
||||
// e.g., "Mathias <mathias@example.com>" the first part of email "<mathias"
|
||||
@ -70,7 +81,7 @@ egw.extend('open', egw.MODULE_WND_LOCAL, function(_egw, _wnd)
|
||||
{
|
||||
if (content[index].length > 0)
|
||||
{
|
||||
var cLen = content[index].split(',');
|
||||
var cLen = content[index];
|
||||
egw.message(egw.lang('%1 email(s) added into %2', cLen.length, egw.lang(index)));
|
||||
return;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user