Skip to content

Regex doesn't handle beginnings in backtracing #5288

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

Closed
Pandapip1 opened this issue Sep 13, 2023 · 7 comments
Closed

Regex doesn't handle beginnings in backtracing #5288

Pandapip1 opened this issue Sep 13, 2023 · 7 comments
Labels
bug Something isn't working jsc Something related to JavaScriptCore

Comments

@Pandapip1
Copy link
Contributor

What version of Bun is running?

1.0.1+31aec4ebe325982fc0ef27498984b0ad9969162b

What platform is your computer?

Linux 5.15.90.1-microsoft-standard-WSL2 x86_64 unknown

What steps can reproduce the bug?

I was originally using NodeJS for my project. I have the following regex to extract github usernames from an author string:

let reviewers = "Hello World (@hello), Neet (@neet), Honk, Foo <[email protected]>".match(/(?<=(?:^|,)[^<(]+\(@)(.*?)(?=\)\s*(<(("[^"]+")|([\w.]+)@[\w.]+)>)?(?:$|,))/g) || [];

What is the expected behavior?

In NodeJS:

> console.dir(reviewers)
[ "hello", "neet" ]

What do you see instead?

In Bun:

> console.dir(reviewers)
[ "neet" ]

Additional information

No response

@Pandapip1 Pandapip1 added the bug Something isn't working label Sep 13, 2023
@Pandapip1 Pandapip1 changed the title Regex Inconsistency Regex test produces incorrect result Sep 13, 2023
@Pandapip1
Copy link
Contributor Author

Pandapip1 commented Sep 13, 2023

Found the issue. It's a combination of back/forward tracing and the start/end symbols. The following code produces correct results until this is fixed:

let reviewers = `,${frontMatter.attributes.author},`?.match(/(?<=(?:^|,)[^<(]+\(@)(.*?)(?=\)\s*(<(("[^"]+")|([\w.]+)@[\w.]+)>)?(?:$|,))/g) || [];

@Pandapip1 Pandapip1 changed the title Regex test produces incorrect result Regex doesn't handle beginnings in backtracing Sep 13, 2023
@Electroid
Copy link
Contributor

This might be fixed by #5167. @dylan-conway want to check?

@Pandapip1
Copy link
Contributor Author

Pandapip1 commented Sep 13, 2023

This might be fixed by #5167. @dylan-conway want to check?

If it is, would it be possible to release a version 1.0.2 sooner rather than later?

@dylan-conway
Copy link
Member

Unfortunately this is a bug in JSC and #5167 does not fix it.

@Electroid Electroid added the jsc Something related to JavaScriptCore label Sep 13, 2023
@dylan-conway
Copy link
Member

This has been fixed in the latest version of safari. We will have this bug fix when we upgrade our WebKit fork

@Pandapip1
Copy link
Contributor Author

We will have this bug fix when we upgrade our WebKit fork

When will that be?

@dylan-conway
Copy link
Member

fixed in v1.0.3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working jsc Something related to JavaScriptCore
Projects
None yet
Development

No branches or pull requests

3 participants