dperini / nwsapi

Fast CSS Selectors API Engine
MIT License
105 stars 36 forks source link

Case insensitivity is not always handled correctly for attribute selectors #60

Closed ypapouski closed 1 year ago

ypapouski commented 2 years ago

The following attribute selector [name=abci] is compiled into if(((/^abc$/i).test(...)... that is obviously incorrect. The correct variant is if(((/^abci$/).test(...)....

The possible fix is located in my fork of your library: https://github.com/dperini/nwsapi/pull/59.

dperini commented 2 years ago

It wasn't an easy revert but should be OK now. Thank you anyway for your help & support.

dperini commented 2 years ago

The fix as been tested and works with all tests passing (including web_platform_tests).

domenic commented 2 years ago

Hi @dperini, any progress on getting this fixed and released to npm? The latest release on npm is still 2.2.1, which has the bug.

dperini commented 2 years ago

@domenic / @ypapouski this is going to be fixed in the next couple of days. Sorry for the delay with this, please just help me decide on the following simplification. Could we fix tag case-sensitivity by turning the complete input to lower case ?

HTML_DOCUMENT && (selectors = selectors.toLowerCase());

This could also lead to speed improvements by removing sparse case conversions and conditional cases I have in place throughout the complete code.

Thank you both for the suggestion you can provide.

domenic commented 2 years ago

That seems wrong. E.g. [foo="bar"] and [foo="BAR"] are very different selectors.

dperini commented 2 years ago

@ypapouski @domenic please check release 2.2.2 on npm.