dperini / nwsapi

Fast CSS Selectors API Engine
MIT License
103 stars 35 forks source link

Attribute selector ~= does not handle escaped values correctly #84

Closed sophiebits closed 1 year ago

sophiebits commented 1 year ago

[rel~="with\5c slashes"] should match an element whose rel is with\slashes, but it doesn't, because the logic here checks if the selector value contains whitespace, not recognizing that whitespace could be part of a valid escape of a non-whitespace character:

https://github.com/dperini/nwsapi/blob/8d71cdfcdeb85800d7c0578476e8bca31d36285b/src/nwsapi.js#L855-L860

Presumably the escapes need to be converted before doing this bailout logic.