Strict Input Validation & Sanitize Message Box Feature
Overview
This feature implements strict input validation for user inputs in various fields, including name, phone number, and message box. The goal is to prevent HTML injection attacks and ensure that only valid characters are accepted.
Validation Rules
* Name Fields: Only letters (a-zA-Z) are allowed.
* Phone Field: Only numbers (0-9) and hyphens (-) are allowed.
* Message Box:
+ Maximum length: 100 characters
+ Allowed characters: Letters, numbers, spaces, punctuation marks (., , !, ?, ', {, }, -)
+ Forbidden characters: Strictly blocked or stripped to prevent HTML tags
Regex Patterns
* First Name: regex: ^[\p{L}]+([\p{L}' -]*[\p{L}])?$
* Last Name: regex: ^[\p{L}]+([\p{L}'. -]*[\p{L}])?$
* Country Code: regex: ^\+[1-9]\d{0,2}$
* Mobile Number (for country code "+1"): regex: ^(\d{6,15}|\d{3}-\d{3}-\d{4})$
* Message Box: regex: /^[^]{0,100}$
Behavior
Scenarios
The feature includes several scenarios to test its behavior, including: