Skip to content
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

LibRegex: Incorrect matches when using variable-width lookbehinds #3459

Open
1 task
aplefull opened this issue Feb 4, 2025 · 2 comments
Open
1 task

LibRegex: Incorrect matches when using variable-width lookbehinds #3459

aplefull opened this issue Feb 4, 2025 · 2 comments
Labels
bug Something isn't working has repro We have a way to reproduce this bug.

Comments

@aplefull
Copy link
Contributor

aplefull commented Feb 4, 2025

Summary

When using lookbehind assertions with quantifiers (.*), match() produces incorrect results. I lost the original source for the reduction, unfortunately

Operating system

Linux

Steps to reproduce

N/A

Expected behavior

Provided in reduced test case

Actual behavior

Provided in reduced test case

URL for a reduced test case

N/A

HTML/SVG/etc. source for a reduced test case

<script>
  const match1 = "a b".match(/(?<=a.*)b/g); // Expected: ["b"], Actual: null
  const match2 = "a b".match(/(?<=a.*).*?/g); // Expected: ["", "", ""], Actual: [""]
  const match3 = "a b".match(/(?<!a.*)(?<=b).*/g); // Expected: null, Actual: [""]

  console.log(match1, match2, match3);
</script>

Log output and (if possible) backtrace

N/A

Screenshots or screen recordings

No response

Build flags or config settings

No response

Contribute a patch?

  • I’ll contribute a patch for this myself.
@AtkinsSJ AtkinsSJ added bug Something isn't working has repro We have a way to reproduce this bug. labels Feb 5, 2025
@AtkinsSJ
Copy link
Member

AtkinsSJ commented Feb 5, 2025

Pinging @alimpfard

@alimpfard
Copy link
Contributor

Ah this nonsense. Yeah this one I am very aware of, I was hoping we'd never see it in the wild :(

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working has repro We have a way to reproduce this bug.
Projects
None yet
Development

No branches or pull requests

3 participants