Fix autoFocus for all elements and ReDoS in devtools stack parsing #35693
Open
d1maash wants to merge 5 commits intofacebook:mainfrom
Open
Fix autoFocus for all elements and ReDoS in devtools stack parsing #35693d1maash wants to merge 5 commits intofacebook:mainfrom
d1maash wants to merge 5 commits intofacebook:mainfrom
Conversation
…acebook#35656) autoFocus is a global HTML attribute per the spec, but React only handled it for button, input, select, and textarea. This change treats autoFocus as a global attribute so it works on any focusable element including anchor tags, div with tabIndex, dialog, details, etc. Changes: - finalizeInitialChildren: default case now returns !!props.autoFocus - commitMount: default case now calls .focus() when autoFocus is set - Added tests for <a autoFocus> and <div tabIndex={0} autoFocus>
…#35490) Fix two regex patterns in parseStackTrace.js vulnerable to catastrophic backtracking: 1. firefoxFrameRegExp: replace overlapping .*".+" with non-overlapping character classes [^@"]*(?:"[^"]*"[^@"]*)* 2. CHROME_STACK_REGEXP: simplify detection regex from /^\s*at .*(\S+:\d+|\(native\))/m to /^\s*at /m to eliminate the O(n^2) backtracking between .* and \S+
Feat/dimash
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.