bun icon indicating copy to clipboard operation
bun copied to clipboard

Certain regex pattern report as SyntaxError

Open terrywh opened this issue 2 years ago • 1 comments

What version of Bun is running?

0.2.1

What platform is your computer?

Darwin 21.6.0 Darwin Kernel Version 21.6.0: Mon Aug 22 20:19:52 PDT 2022; root:xnu-8020.140.49~2/RELEASE_ARM64_T6000 arm64 arm

What steps can reproduce the bug?

const regex_is_single_css_selector = /[^\\],(?!([^([]+[^\\]|[^([\\])[)\]])/;

How often does it reproduce? Is there a required condition?

with certain non-escaped charactor in regex pattern.

What is the expected behavior?

consider the above regex legal as in chrome / node / firefox does.

What do you see instead?

image

SyntaxError: Invalid regular expression: premature end of char-class

Additional information

No response

terrywh avatar Oct 26 '22 12:10 terrywh

I'm getting an issue with regex too. For me it's caused by this module (no issues with this module from Node.js or Deno; something too strict in parsing?):

https://github.com/markdown-it/uc.micro/blob/master/properties/Any/regex.js

1 | __cJS2eSM
2 | } from "bun:wrap";
3 | export default __cJS2eSM(function(module, exports) {
4 |
5 |   module.exports = (new globalThis.Bun.OnigurumaRegExp("[\\0-\\uD7FF\\uE000-\\uFFFF]|[\\uD800-\\uDBFF][\\uDC00-\\uDFFF]|[\\uD800-\\uDBFF](?![\\uDC00-\\uDFFF])|(?:[^\\uD800-\\uDBFF]|^)[\\uDC00-\\uDFFF]"));
                  ^
SyntaxError: Invalid regular expression: too short multibyte code string
      at /home/kelsey/projects/js/documents-web/node_modules/uc.micro/properties/Any/regex.js:1:15
      at bun:wrap:1:16360
      at /home/kelsey/projects/js/documents-web/node_modules/uc.micro/index.js:3:22
      at bun:wrap:1:16360
      at /home/kelsey/projects/js/documents-web/node_modules/markdown-it/lib/common/utils.js:300:38
      at bun:wrap:1:16360
      at /home/kelsey/projects/js/documents-web/node_modules/markdown-it/lib/index.js:6:27
      at bun:wrap:1:16360
      at /home/kelsey/projects/js/documents-web/node_modules/markdown-it/index.js:4:25
      at bun:wrap:1:16360
      at /home/kelsey/projects/js/documents-web/index.js:2:0

Bun version also 0.2.1.

kj avatar Oct 26 '22 14:10 kj

My specific issue at least seems to be fixed now in Bun 0.2.2, I guess due to this:

https://github.com/oven-sh/bun/pull/1363

kj avatar Oct 30 '22 07:10 kj

My specific issue at least seems to be fixed now in Bun 0.2.2, I guess due to this:

#1363

tested on v0.2.2 my problems are fixed.

terrywh avatar Oct 31 '22 07:10 terrywh