Issue
The regex custom validator in jquery.validate.unobtrusive.js (shipped with ASP.NET Core Identity UI) throws a SyntaxError when new RegExp(params) encounters an invalid regex pattern from data-val-regex-pattern. This crashes all client-side form validation on the page.
Steps to Reproduce
A [RegularExpression] attribute with an invalid pattern (e.g., unbalanced brackets) generates a data-val-regex-pattern attribute. When jQuery Validate evaluates new RegExp(params), it throws.
Proposed Fix
Wrap the new RegExp() call in a try-catch so invalid patterns skip validation gracefully instead of crashing. Server-side validation at form submission remains the authoritative fallback.
Found via static analysis of the ASP.NET Core codebase.
Issue
The
regexcustom validator injquery.validate.unobtrusive.js(shipped with ASP.NET Core Identity UI) throws aSyntaxErrorwhennew RegExp(params)encounters an invalid regex pattern fromdata-val-regex-pattern. This crashes all client-side form validation on the page.Steps to Reproduce
A
[RegularExpression]attribute with an invalid pattern (e.g., unbalanced brackets) generates adata-val-regex-patternattribute. When jQuery Validate evaluatesnew RegExp(params), it throws.Proposed Fix
Wrap the
new RegExp()call in a try-catch so invalid patterns skip validation gracefully instead of crashing. Server-side validation at form submission remains the authoritative fallback.Found via static analysis of the ASP.NET Core codebase.