browserslist/browserslist-useragent-regexp

Nonnumeric browser versions + allowHigherVersions causes all versions to be in the range

rayproud-pp opened this issue ยท 5 comments

Hey!

We've discovered an interesting issue.
When we use unreleased versions in our .browserslistrc with allowHigherVersions in the browserslist-useragent-regexp setting, the result regex matches all versions of Safari.

After some debugging, we found out that having unreleased versions in .browserslistrc results in having Safari TP among Safari versions. Which can't be handled by the semverify function. There's even a comment says "risky" there ๐Ÿ˜…

Anyway, "Safari TP" turns into 0.0.0, which, with the allowHigherVersions flag, makes the whole browserslist setting useless โ€” the result regex included everything that's greater than 0.
Screenshot 2021-09-01 at 14 55 11

This is the result regex:
(Version\/(0|([1-9]|\d{2,})|12|(1[3-9]|[2-9]\d|\d{3,})|13|(1[4-9]|[2-9]\d|\d{3,})|14|(1[5-9]|[2-9]\d|\d{3,})|15|(1[6-9]|[2-9]\d|\d{3,}))\.\d+(?:\.\d+)? Safari\/)

instead of awaited
(Version\/(12|(1[3-9]|[2-9]\d|\d{3,})|13|(1[4-9]|[2-9]\d|\d{3,})|14|(1[5-9]|[2-9]\d|\d{3,})|15|(1[6-9]|[2-9]\d|\d{3,}))\.\d+(?:\.\d+)? Safari\/).

Data for debugging:
.browserslistrc for testing:

unreleased versions
last 2 years
last 3 major versions
not dead
not ie <= 11
not ie_mob <= 11

Version of browserslist-useragent-regexp โ€” 3.0.0
Version of node โ€” 14.17

Hey @dangreen!
Will you have time next week to take a look at the issue?

If not, I can help with a PR, just drop me a line ๐Ÿ™‚

@rayproud-pp Hi! Yes, I will get it soon.

@dangreen, any updates on this issue?

Fixed in v3.0.1

@rayproud-pp Hi. Did you test fix?