Fix autoFocus for all elements and ReDoS in devtools stack parsing #35693
+78
−3
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
This PR addresses two open issues:
1. Support autoFocus as a global HTML attribute
(#35656)
autoFocusis a [global HTMLattribute](https://developer.mozilla.org/en-US/docs/W
eb/HTML/Global_attributes/autofocus) per the spec,
but React only handled it for
button,input,select, andtextarea. This change treatsautoFocusas a global attribute so it works onany focusable element — anchor tags,
<div tabIndex={0}>,<dialog>,<details>, etc.Changes:
finalizeInitialChildren: default case now returns!!props.autoFocuscommitMount: default case now calls.focus()when
autoFocusis set<a autoFocus>and<div tabIndex={0} autoFocus>2. Fix ReDoS vulnerabilities in stack trace
parsing (#35490)
Two regex patterns in
parseStackTrace.jsarevulnerable to catastrophic backtracking:
firefoxFrameRegExp:(?:.*".+")?[^@]*contains overlapping quantifiers. Replaced with
[^@"]*(?:"[^"]*"[^@"]*)*using non-overlappingcharacter classes.
CHROME_STACK_REGEXP:.*(\S+:\d+|\(native\))causes O(n²) backtracking. Simplified to
/^\s*at /m.