mirror of
https://github.com/InvoiceShelf/InvoiceShelf.git
synced 2026-04-15 09:14:08 +00:00
Support internationalized domain names (IDN) in email validation
Add IdnEmail validation rule that converts IDN domains to Punycode via idn_to_ascii() before validating with FILTER_VALIDATE_EMAIL. Applied to all email fields: customers, members, profiles, admin users, customer portal profiles, and mail configuration. Includes unit tests for standard emails, IDN emails, and invalid inputs. Fixes #388
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Http\Requests;
|
||||
|
||||
use App\Rules\IdnEmail;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Validation\Rule;
|
||||
|
||||
@@ -18,7 +19,7 @@ class AdminUserUpdateRequest extends FormRequest
|
||||
'name' => ['required', 'string'],
|
||||
'email' => [
|
||||
'required',
|
||||
'email',
|
||||
new IdnEmail,
|
||||
Rule::unique('users')->ignore($this->route('user')),
|
||||
],
|
||||
'phone' => ['nullable', 'string'],
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
namespace App\Http\Requests\Customer;
|
||||
|
||||
use App\Models\Address;
|
||||
use App\Rules\IdnEmail;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Validation\Rule;
|
||||
@@ -32,7 +33,7 @@ class CustomerProfileRequest extends FormRequest
|
||||
],
|
||||
'email' => [
|
||||
'nullable',
|
||||
'email',
|
||||
new IdnEmail,
|
||||
Rule::unique('customers')->where('company_id', $this->header('company'))->ignore(Auth::id(), 'id'),
|
||||
],
|
||||
'billing.name' => [
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
namespace App\Http\Requests;
|
||||
|
||||
use App\Models\Address;
|
||||
use App\Rules\IdnEmail;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Support\Arr;
|
||||
use Illuminate\Validation\Rule;
|
||||
@@ -27,7 +28,7 @@ class CustomerRequest extends FormRequest
|
||||
'required',
|
||||
],
|
||||
'email' => [
|
||||
'email',
|
||||
new IdnEmail,
|
||||
'nullable',
|
||||
Rule::unique('customers')->where('company_id', $this->header('company')),
|
||||
],
|
||||
@@ -116,7 +117,7 @@ class CustomerRequest extends FormRequest
|
||||
|
||||
if ($this->isMethod('PUT') && $this->email != null) {
|
||||
$rules['email'] = [
|
||||
'email',
|
||||
new IdnEmail,
|
||||
'nullable',
|
||||
Rule::unique('customers')->where('company_id', $this->header('company'))->ignore($this->route('customer')->id),
|
||||
];
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Http\Requests;
|
||||
|
||||
use App\Rules\IdnEmail;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Validation\Rule;
|
||||
|
||||
@@ -26,7 +27,7 @@ class MemberRequest extends FormRequest
|
||||
],
|
||||
'email' => [
|
||||
'required',
|
||||
'email',
|
||||
new IdnEmail,
|
||||
Rule::unique('users'),
|
||||
],
|
||||
'phone' => [
|
||||
@@ -50,7 +51,7 @@ class MemberRequest extends FormRequest
|
||||
if ($this->getMethod() == 'PUT') {
|
||||
$rules['email'] = [
|
||||
'required',
|
||||
'email',
|
||||
new IdnEmail,
|
||||
Rule::unique('users')->ignore($this->user),
|
||||
];
|
||||
$rules['password'] = [
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Http\Requests;
|
||||
|
||||
use App\Rules\IdnEmail;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Validation\Rule;
|
||||
@@ -31,7 +32,7 @@ class ProfileRequest extends FormRequest
|
||||
],
|
||||
'email' => [
|
||||
'required',
|
||||
'email',
|
||||
new IdnEmail,
|
||||
Rule::unique('users')->ignore(Auth::id(), 'id'),
|
||||
],
|
||||
];
|
||||
|
||||
Reference in New Issue
Block a user