Skip to content

馃悰 match textarea pattern polyfill against the whole value - #40542

Open
madib06ops wants to merge 1 commit into
ampproject:mainfrom
madib06ops:textarea-pattern-anchor
Open

馃悰 match textarea pattern polyfill against the whole value#40542
madib06ops wants to merge 1 commit into
ampproject:mainfrom
madib06ops:textarea-pattern-anchor

Conversation

@madib06ops

Copy link
Copy Markdown
Contributor

The textarea pattern polyfill in checkInputValidity compiles the author pattern as new RegExp('^' + pattern + '$', 'm'), which does not match native <input pattern> semantics. The m flag lets ^ and $ match at internal line breaks, and without a non-capturing group a top-level alternation such as cat|dog only anchors one branch, so a value whose first line matches (abc\nanything against [a-z]+) or that merely starts or ends with an alternative passes validation. Compiling as ^(?:pattern)$ with no flags applies the pattern to the whole value the way the browser does.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant