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

Run test suite on browsers #19

Open
frangio opened this issue Dec 12, 2019 · 8 comments
Open

Run test suite on browsers #19

frangio opened this issue Dec 12, 2019 · 8 comments

Comments

@frangio
Copy link
Collaborator

frangio commented Dec 12, 2019

We're currently running the test suite in Node.js only. We should also run it in the browser.

@ajb413
Copy link

ajb413 commented Jul 12, 2022

That would be great! Can confirm that there is a regex error for this plugin in safari but not other browsers.

SyntaxError: Invalid regular expression: invalid group specifier name

@joshgoebel
Copy link
Member

What version of Safari and what version of Mac OS?

@ajb413
Copy link

ajb413 commented Jul 12, 2022

Safari Version 15.4 (17613.1.17.1.13)
Monterey 12.3.1

@joshgoebel
Copy link
Member

@ajb413 Can you get us as stack trace of the error?

@ajb413
Copy link

ajb413 commented Jul 13, 2022

Breaks on line 1172 of a fresh common js build of Highlight.js v11.5.0 (git: 6fc781508b). I added a log line so you can see the bad input of value. I pasted the common js build into my min file so don't be confused by that in the screenshot.

-?((?<!\$)\b0[xX]([a-fA-F0-9]_?)*[a-fA-F0-9]|((?<!\$)\b[1-9](_?\d)*(\.((\d_?)*\d)?)?|\.\d(_?\d)*)([eE][-+]?\d(_?\d)*)?|(?<!\$)\b0)(?!\w|\$)

Screen Shot 2022-07-12 at 8 16 03 PM

Edit: Looks like that comes from this line here: https://github.com/highlightjs/highlightjs-solidity/blob/master/src/common.js#L27

Edit: Seeing same error on v10.7.3 and v10.4.1

@joshgoebel
Copy link
Member

That's trying to put together a regex with negative look-behinds... but the library has a check for that, so I'm not sure what is going on there.

@ajb413
Copy link

ajb413 commented Aug 27, 2022

I had some time to dig on this. I got my minified version (@2.0.5/dist/solidity.min.js) from jsdelivr.com. It looks like there was a build issue. You can see that file here.

The negative look behind check is simply omitted from the minified build.

Screen Shot 2022-08-26 at 7 52 47 PM

You can see it is the first function at the top, after the "use strict" in the minified file.

Screen Shot 2022-08-26 at 7 50 07 PM

If you change the try/catch in the minified file to this:

function e(){try{new RegExp('(?<!.)');return!0
}catch(e){return!1}}

then that check actually happens, and that Safari error goes away, and the package works properly

Screen Shot 2022-08-26 at 7 56 06 PM

@joshgoebel
Copy link
Member

Perhaps minified build needs different minifier arguments to not compile out the check?

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

No branches or pull requests

3 participants