-
-
Notifications
You must be signed in to change notification settings - Fork 179
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
v8 development #559
base: main
Are you sure you want to change the base?
v8 development #559
Conversation
🦋 Changeset detectedLatest commit: 4085815 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
const TEXT_STRIKETHROUGHED_R = new RegExp(`^~~${INLINE_SKIP_R}~~`) | ||
// https://regexr.com/7u91c | ||
const INLINE_FORMATTING_R = | ||
/^(([*_])\2|[*_]|~~|==)((?:\[.*?\][([].*?[)\]]|<.*?>(?:.*?<.*?>)?|([*_]+|`|~~|==)[\s\S]+?\4|[\s\S])+?)\1/ |
Check failure
Code scanning / CodeQL
Inefficient regular expression High
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix AI 21 days ago
To fix the problem, we need to refactor the regular expression to remove the ambiguity and nested quantifiers that cause exponential backtracking. This can be achieved by breaking down the regular expression into simpler, non-ambiguous parts and ensuring that each part matches a specific pattern without overlap.
In this case, we can refactor the regular expression to handle each part separately and avoid nested quantifiers. We will replace the problematic part with a more efficient pattern that achieves the same functionality.
-
Copy modified line R230
@@ -229,3 +229,3 @@ | ||
const INLINE_FORMATTING_R = | ||
/^(([*_])\2|[*_]|~~|==)((?:\[.*?\][([].*?[)\]]|<.*?>(?:.*?<.*?>)?|([*_]+|`|~~|==)[\s\S]+?\4|[\s\S])+?)\1/ | ||
/^(([*_])\2|[*_]|~~|==)((?:\[.*?\][([].*?[)\]]|<[^<>]*>(?:<[^<>]*>)*|([*_]+|`|~~|==)[\s\S]+?\4|[\s\S])+?)\1/ | ||
|
const TEXT_STRIKETHROUGHED_R = new RegExp(`^~~${INLINE_SKIP_R}~~`) | ||
// https://regexr.com/7u91c | ||
const INLINE_FORMATTING_R = | ||
/^(([*_])\2|[*_]|~~|==)((?:\[.*?\][([].*?[)\]]|<.*?>(?:.*?<.*?>)?|([*_]+|`|~~|==)[\s\S]+?\4|[\s\S])+?)\1/ |
Check failure
Code scanning / CodeQL
Inefficient regular expression High
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix AI 21 days ago
To fix the problem, we need to modify the regular expression to remove the ambiguity that causes exponential backtracking. Specifically, we should replace the .*?
pattern with a more specific pattern that avoids ambiguity. In this case, we can use a negated character class to match any character except the ones that would cause backtracking issues.
- Modify the regular expression on line 230 to replace
.*?
with a more specific pattern. - Ensure that the new pattern maintains the existing functionality of the regular expression.
-
Copy modified line R230
@@ -229,3 +229,3 @@ | ||
const INLINE_FORMATTING_R = | ||
/^(([*_])\2|[*_]|~~|==)((?:\[.*?\][([].*?[)\]]|<.*?>(?:.*?<.*?>)?|([*_]+|`|~~|==)[\s\S]+?\4|[\s\S])+?)\1/ | ||
/^(([*_])\2|[*_]|~~|==)((?:\[.*?\][([][^)\]]*?[)\]]|<[^>]*>(?:[^<]*?<[^>]*?>)?|([*_]+|`|~~|==)[\s\S]+?\4|[\s\S])+?)\1/ | ||
|
const TEXT_STRIKETHROUGHED_R = new RegExp(`^~~${INLINE_SKIP_R}~~`) | ||
// https://regexr.com/7u91c | ||
const INLINE_FORMATTING_R = | ||
/^(([*_])\2|[*_]|~~|==)((?:\[.*?\][([].*?[)\]]|<.*?>(?:.*?<.*?>)?|([*_]+|`|~~|==)[\s\S]+?\4|[\s\S])+?)\1/ |
Check failure
Code scanning / CodeQL
Inefficient regular expression High
Copilot Autofix AI 21 days ago
Copilot could not generate an autofix suggestion
Copilot could not generate an autofix suggestion for this alert. Try pushing a new commit or if the problem persists contact support.
const TEXT_STRIKETHROUGHED_R = new RegExp(`^~~${INLINE_SKIP_R}~~`) | ||
// https://regexr.com/7u91c | ||
const INLINE_FORMATTING_R = | ||
/^(([*_])\2|[*_]|~~|==)((?:\[.*?\][([].*?[)\]]|<.*?>(?:.*?<.*?>)?|([*_]+|`|~~|==)[\s\S]+?\4|[\s\S])+?)\1/ |
Check failure
Code scanning / CodeQL
Inefficient regular expression High
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix AI 21 days ago
To fix the problem, we need to modify the regular expression to remove the ambiguity that causes exponential backtracking. Specifically, we should replace the .*?
pattern with a more specific pattern that avoids the inefficiency.
- We will replace
.*?
with a pattern that matches any character except for the ones that could cause backtracking issues. - The new pattern will be
[^*<]*?
which matches any character except*
and<
, thus preventing the problematic backtracking scenario.
-
Copy modified line R230
@@ -229,3 +229,3 @@ | ||
const INLINE_FORMATTING_R = | ||
/^(([*_])\2|[*_]|~~|==)((?:\[.*?\][([].*?[)\]]|<.*?>(?:.*?<.*?>)?|([*_]+|`|~~|==)[\s\S]+?\4|[\s\S])+?)\1/ | ||
/^(([*_])\2|[*_]|~~|==)((?:\[.*?\][([].*?[)\]]|<[^*<]*?>(?:[^*<]*?<[^*<]*?>)?|([*_]+|`|~~|==)[\s\S]+?\4|[\s\S])+?)\1/ | ||
|
const TEXT_STRIKETHROUGHED_R = new RegExp(`^~~${INLINE_SKIP_R}~~`) | ||
// https://regexr.com/7u91c | ||
const INLINE_FORMATTING_R = | ||
/^(([*_])\2|[*_]|~~|==)((?:\[.*?\][([].*?[)\]]|<.*?>(?:.*?<.*?>)?|([*_]+|`|~~|==)[\s\S]+?\4|[\s\S])+?)\1/ |
Check failure
Code scanning / CodeQL
Inefficient regular expression High
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix AI 21 days ago
To fix the problem, we need to modify the regular expression to remove the ambiguity that causes exponential backtracking. Specifically, we should replace the .*?
pattern with a more precise pattern that avoids ambiguity. In this case, we can use a negated character class to match any character except the ones that would cause backtracking.
- Identify the problematic regular expression on line 230.
- Replace the
.*?
pattern with a negated character class that matches any character except the ones that would cause backtracking. - Ensure that the new pattern maintains the original functionality of the regular expression.
-
Copy modified line R230
@@ -229,3 +229,3 @@ | ||
const INLINE_FORMATTING_R = | ||
/^(([*_])\2|[*_]|~~|==)((?:\[.*?\][([].*?[)\]]|<.*?>(?:.*?<.*?>)?|([*_]+|`|~~|==)[\s\S]+?\4|[\s\S])+?)\1/ | ||
/^(([*_])\2|[*_]|~~|==)((?:\[.*?\][([][^)\]]*|<.*?>(?:.*?<.*?>)?|([*_]+|`|~~|==)[\s\S]+?\4|[\s\S])+?)\1/ | ||
|
const TEXT_STRIKETHROUGHED_R = new RegExp(`^~~${INLINE_SKIP_R}~~`) | ||
// https://regexr.com/7u91c | ||
const INLINE_FORMATTING_R = | ||
/^(([*_])\2|[*_]|~~|==)((?:\[.*?\][([].*?[)\]]|<.*?>(?:.*?<.*?>)?|([*_]+|`|~~|==)[\s\S]+?\4|[\s\S])+?)\1/ |
Check failure
Code scanning / CodeQL
Inefficient regular expression High
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix AI 21 days ago
To fix the problem, we need to modify the regular expression to remove the ambiguity that causes exponential backtracking. Specifically, we can replace .*?
with a more specific pattern that avoids the inefficiency. In this case, we can use a negated character class to match any character except the ones that would cause backtracking issues.
- Replace
.*?
with a more specific pattern that avoids ambiguity and backtracking. - Ensure the new pattern maintains the original functionality of the regular expression.
-
Copy modified line R230
@@ -229,3 +229,3 @@ | ||
const INLINE_FORMATTING_R = | ||
/^(([*_])\2|[*_]|~~|==)((?:\[.*?\][([].*?[)\]]|<.*?>(?:.*?<.*?>)?|([*_]+|`|~~|==)[\s\S]+?\4|[\s\S])+?)\1/ | ||
/^(([*_])\2|[*_]|~~|==)((?:\[.*?\][([].*?[)\]]|<[^>]*>(?:.*?<[^>]*>)?|([*_]+|`|~~|==)[\s\S]+?\4|[\s\S])+?)\1/ | ||
|
This comment was marked as off-topic.
This comment was marked as off-topic.
f070ddf
to
1a8a393
Compare
This allows for direct use of the markdown-to-jsx AST if it's preferable for your use case to retain full control over output. refactor: isolate React rendering rules chore: upgrade dependencies refactor: consolidate formatted text rules chore: update dependencies refactor: react 16 refactor: remove top-level compiler export refactor: moving things around chore: update benchmark refactor: improve typings refactor: refactor rules into tuple array, add disable/enableRules feat: add custom rule support forward-port fixes from 7.x
1a8a393
to
4085815
Compare
Objectives
allow for multiple rendering targets (react, solid, etc)punting this one to a future major so this can be released fasterpotentially update the library name if we support rendering targets other than JSXpunting this one to a future major so this can be released faster