Skip to content

Lookbehind in number regexp crashes Safari #106

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
tmadeira opened this issue Mar 14, 2023 · 0 comments · Fixed by #107
Closed

Lookbehind in number regexp crashes Safari #106

tmadeira opened this issue Mar 14, 2023 · 0 comments · Fixed by #107

Comments

@tmadeira
Copy link
Contributor

Describe the bug
The regular expression at https://github.com/scriptcoded/sql-highlight/blob/master/lib/index.js#L42 uses lookbehind, which is currently not supported by latest Safari (https://caniuse.com/js-regexp-lookbehind) and some other browsers; caniuse says that its global support is 76.9%. Safari considers that the code has a syntax error, crashing the page.

To Reproduce

  1. Import sql-highlight getSegments in your browser bundle.
  2. Load your page on Safari.
  3. Page crashes with "syntax error: invalid regular expression: invalid group specifier name".

(Or just type /((?<![a-zA-z])\d+(?:\.\d+)?)/g on Safari console.)

Expected behavior
Code should compile.

sql-highlight (please complete the following information):
v4.3.1 (latest)

Node.js (please complete the following information):
Not applicable.

Browser (please complete the following information):
MacOS Safari 16.3 (latest)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant