You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The Typescript types for getBrowserVersion state that it always returns a string. However, if the version string cannot be parsed from the browser's user agent string, the code never sets browser.version, causing it to be undefined in some cases.
This caused a runtime error in our application because we assumed the function would always return a string, but it did not. These types are misleading and should be corrected.
You can reproduce this issue with the following mangled user agent string: Mozilla/5.0 (Linux; U; Android 4.0.2; en-us; Galaxy Nexus Build/ICL53F) AppleWebKit/534.30 (KHTML, like Gecko) Version 4.0 Mobile Safari/534.30. This is a contrived example (Version/4.0 was replaced with Version 4.0) but it demonstrates that the library sometimes returns undefined. Since user agent strings are effectively user input, this issue can (and does) happen in the wild.
The text was updated successfully, but these errors were encountered:
https://github.com/lancedikson/bowser/blob/f09411489ced05811c91cc6670a8e4ca9cbe39a7/index.d.ts#L57
The Typescript types for
getBrowserVersion
state that it always returns astring
. However, if theversion
string cannot be parsed from the browser's user agent string, the code never setsbrowser.version
, causing it to beundefined
in some cases.Example:
https://github.com/lancedikson/bowser/blob/f09411489ced05811c91cc6670a8e4ca9cbe39a7/src/parser-browsers.js#L40-L42
This caused a runtime error in our application because we assumed the function would always return a string, but it did not. These types are misleading and should be corrected.
You can reproduce this issue with the following mangled user agent string:
Mozilla/5.0 (Linux; U; Android 4.0.2; en-us; Galaxy Nexus Build/ICL53F) AppleWebKit/534.30 (KHTML, like Gecko) Version 4.0 Mobile Safari/534.30
. This is a contrived example (Version/4.0
was replaced withVersion 4.0
) but it demonstrates that the library sometimes returns undefined. Since user agent strings are effectively user input, this issue can (and does) happen in the wild.The text was updated successfully, but these errors were encountered: