Coder Social home page Coder Social logo

polyfill-useragent-normaliser's People

Contributors

avgp avatar christianhaller3000 avatar dependabot-preview[bot] avatar dependabot[bot] avatar jakechampion avatar mhassan1 avatar origamiserviceuser avatar plesiecki avatar semantic-release-bot avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

polyfill-useragent-normaliser's Issues

Polyfill breaks websites on Pale Moon (XMLHTTPRequest?)

Bug report

What

  • Misdetection of Pale Moon (and potentially other Firefox forks)
  • XMLHTTPRequest polyfill wrong, resulting in:
    TypeError: 'dispatchEvent' called on an object that does not implement interface EventTarget.

Details

I ran into this on PayPal of all places, breaking their web interface and preventing me from doing pretty much anything! This is a critical problem.
The console was spammed with the following types of errors:

18:55:39.359 TypeError: 'dispatchEvent' called on an object that does not implement interface EventTarget. 1 polyfill.js:6652:4
	XMLHttpRequest/nativeRequest.onreadystatechange https://cdn.polyfill.io/v3/polyfill.js:6652:4
	e.exports/n.onreadystatechange https://www.paypalobjects.com/web/res/*****/js/xhr-ads.min.js:1:17248
	e.exports/c.open https://www.paypalobjects.com/web/res/*****/js/xhr-ads.min.js:1:16760
	open https://cdn.polyfill.io/v3/polyfill.js:6692:3
	chatAsyncUtils/this.doGet https://www.paypal.com/smarthelp/js/minihelp/helpcenter-8ball-spark.js:410:7
	mountChat https://www.paypal.com/smarthelp/js/minihelp/helpcenter-8ball-spark.js:449:7
	helpcenter8ballSpark https://www.paypal.com/smarthelp/js/minihelp/helpcenter-8ball-spark.js:492:3
	<anonymous> https://www.paypal.com/smarthelp/js/minihelp/helpcenter-8ball-spark.js:23:11

And it would hang and block any action on their site.

A workaround was to feed polyfill.io an "official" Firefox useragent with a site-specific override:
Mozilla/5.0 (Windows NT 6.1; WOW64; rv:60.9) Gecko/20100101 Firefox/60.9

Our normal Firefox-compat UA string does NOT work and makes the lib bork:
Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:60.9) Gecko/20100101 Goanna/4.1 Firefox/60.9 PaleMoon/28.4.0
As an aside, we have 2 other UA modes our users may be using:

  • Native: Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:60.9) Goanna/4.1 PaleMoon/28.4.0
  • Gecko compatibility: Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:60.9) Gecko/20100101 Goanna/4.1 PaleMoon/28.4.0

Additional information

Why are you not doing feature detection and are you relying on UA sniffing instead? Why are you overwriting functions like XHR which already exist?
Or for that matter: why are you polyfilling anything if you don't recognize a UA?

Instagram ua

Mozilla/5.0 (iPhone; CPU iPhone OS 9_3_2 like Mac OS X) AppleWebKit/601.1.46 (KHTML, like Gecko) Mobile/13F69 Instagram 8.4.0 (iPhone7,2; iPhone OS 9_3_2; nb_NO; nb-NO; scale=2.00; 750x1334

Should return the ios_saf ua

Snapchat webview is not recognized as safari

Here is the user agent:

Mozilla/5.0 (iPhone; CPU iPhone OS 10_2_1 like Mac OS X) AppleWebKit/602.4.6 (KHTML, like Gecko) Snapchat/10.44.1.1 (iPhone7,2; iOS 10.2.1; gzip)

https://cdn.polyfill.io/v2/polyfill.js?features=default&ua=Mozilla/5.0%20(iPhone;%20CPU%20iPhone%20OS%2010_2_1%20like%20Mac%20OS%20X)%20AppleWebKit/602.4.6%20(KHTML,%20like%20Gecko)%20Snapchat/10.44.1.1%20(iPhone7,2;%20iOS%2010.2.1;%20gzip)

UA detected: ios_saf/0.0.0 (unknown/unsupported; using policy unknown=ignore)

Do you think it is possible to use AppleWebKit version instead of safari when "ios_saf" is recognized ?

Release 1.8.0?

Hey there - I'm curious when the fix for Googlebot is being released in the next version of the library and when this will approximately upstream to polyfill.io? We're seeing a few websites experiencing degraded rendering and wanted to check with y'all what the timeline looks like :)

Webview Safari UA without extension is detected in wrong version

Hi @mhassan1 and @JakeChampion
Thanks for the cool polyfill service.
We use it in an AWS Edge Lambda and are pretty happy.

with one exception: when requests are coming from our iOS app, too much polyfills are served

example:
Mozilla/5.0 (iPhone; CPU iPhone OS 15_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148

this UA is detected as ios_saf/11.0.0

Do you have an idea how to solve this?

I made two failing tests, but no solution
#174

QQ Browser is not recognised.

Background

The QQ Browser is a browser developed by Tencent.

An example user agent from it is:
Mozilla/5.0 (Linux; U; Android 9; zh-cn; vivo X21 Build/PKQ1.180819.001) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/66.0.3359.126 MQQBrowser/9.9 Mobile Safari/537.36

With the current detection this will show the family as chrome 66.

However, this browser does not support everything that Chrome supports (e.g. the Intl API) which leads to errors in polyfilling.

Do you think it's worth differentiating the QQ browser from Chrome?

MZBrowser incorrectly identified as Chrome

The MZBrowser is a browser shipped with the custom Android OS: FlymeOS .

An example user agent from it is:
Mozilla/5.0 (Linux; U; Android 5.1; zh-CN; MZ-M3s Build/MRA58K) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/57.0.2987.108 MZBrowser/8.1.310-2020040818 UWS/2.15.0.4 Mobile Safari/537.36

With the current detection this will show the family as chrome 57.

However, this browser does not support everything that Chrome supports (e.g. the Intl API) which leads to errors in polyfilling.

This is very similar to #27 .

LICENSE

Where is the license file for this OSS?

Android Browser 4 is incorrectly identified as 5

I have noticed that some user agents that should be Android Browser 4 are being labelled as 5.

This means they don't get given the Array.prototype.find polyfill as they should be.

Some offending user agents are:

  • Mozilla/5.0 (Linux; U; Android 5.1.1; ca-es; HUAWEI Y560-L01 Build/HUAWEIY560-L01) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Mobile Safari/537.36
  • Mozilla/5.0 (Linux; U; Android 5.1; en-us; HUAWEI TIT-U02 Build/HUAWEI TIT-U02) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Mobile Safari/537.36
  • Mozilla/5.0 (Linux; U; Android 5.1.1; it-it; HUAWEI Y560-L01 Build/HUAWEIY560-L01) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Mobile Safari/537.36
  • Mozilla/5.0 (Linux; U; Android 5.1.1; en-US; HUAWEI SCL-U31 Build/HuaweiSCL-U31) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 OPR/15.0.2125.101256 Mobile Safari/537.36
  • Mozilla/5.0 (Linux; U; Android 5.1.1; fr-fr; T01 Build/LMY47V) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Mobile Safari/537.36

Is it due the Android OS version being used instead of the Version/4.0 labelling of the browser version?

[bug-report] webpagetest user agent

What

I noticed when running some tests via webpagetest / Chrome 75 that it downloads ~80k of polyfills. This appears to be due to the User Agent extension that WPT adds.

It would be great if the polyfill service were able to handle requests from webpagetest as if they were real user requests, just so we could compare consistently, but it's not a huge deal because I don't think it affects any real users.

Details

The below request uses the webpagetest User Agent. The user agent is normalized to other which I assume assigns the request the default set of polyfills?

curl -IH 'User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3770.142 Safari/537.36 PTST/190709.170756' "https://polyfill.io/v3/polyfill.min.js"

normalized-user-agent: other/0.0.0
detected-user-agent: WebPageTest.org bot/190709.170756
content-length: 82547

This request is identical except I've stripped the latter part of the UA. Now it's parsed normally as Chrome and serves no polyfills.

curl -IH 'User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3770.142 Safari/537.36 PTST' "https://polyfill.io/v3/polyfill.min.js"

normalized-user-agent: chrome/75.0.0
detected-user-agent: Chrome/75.0.3770
content-length: 72

Bug: IOS 14 getting detected as IOS 11.0

Bug Report

What

Safari and Chrome on IOS 14 get detected as IOS 11, and thus get unnecessary polyfills.

Details

As an example: https://polyfill.io/v3/polyfill.js?features=Promise.prototype.finally gets Promise.prototype.finally polyfilled for iOS 14, when it has been supported since 11.3: https://caniuse.com/promise-finally

Using the normalizeUa endpoint with UA Strings from my phone for Chrome and Safari:

λ curl https://polyfill.io/v3/normalizeUa -H "user-agent: Mozilla/5.0 (iPhone; CPU iPhone OS 14_5 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) CriOS/91.0.4472.80 Mobile/15E148 Safari/604.1
ios_saf/11.0.0

λ curl https://polyfill.io/v3/normalizeUa -H "user-agent: Mozilla/5.0 (iPhone; CPU iPhone OS 14_5 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.1 Mobile/15E148 Safari/604.1"
ios_saf/11.0.0

yandex browser on ios should be aliased to ios saf

"Mozilla/5.0 (iPhone; CPU iPhone OS 12_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/12.0 YaBrowser/18.10.3.114.10 Mobile/15E148 Safari/605.1" gets reported as "other/0.0.0" but is parsed as "Yandex Browser/18.10.3" by the underlying parser. We should make it return the ios version instead.

Instagram App on iOS 15.4 is detected as iOS 11

hi @JakeChampion and team,
this user agent Mozilla/5.0 (iPhone; CPU iPhone OS 15_4_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148 Instagram 232.0.0.12.114 (iPhone14,3; iOS 15_4_1; de_DE; de-DE; scale=3.00; 1284x2778; 365562048) NW/1
is normalized as ios_saf/11.0.0

[Issue] attempting to change value of a read-only property

What

I found an error where the webview service using polyfill.io
It was an issue of 'attempting to change value of a read-only property'
image
imageI think it insert the polyfill code even though I have a Symbol.asyncIterator

This is my useragent in the environment where the issue occurred
image

Details

Command the curl below at the terminal, can see that the user agent is parsed

curl -XGET "https://polyfill.io/v3/polyfill.min.js?features=es2018" \
   -H "User-Agent: Mozilla/5.0 (iPhone; CPU iPhone OS 15_1_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148" -v
image

This User-Agent Header's safari version 11 right?

Waterfox 56.2.12 detected as “unknown”, rather than “firefox/56”

Bug Report

What

When a website requests from within Waterfox the URL https://cdn.polyfill.io/v2/polyfill.min.js?unknown=polyfill&rum=0 , polyfill.io will detect this as:

normalized-user-agent | other/0.0.0
detected-user-agent | Waterfox/56.2.12

causing a huge load of polyfills to be loaded:

    • Object.defineProperty, License: CC0 (required by "default", "Array.from", "Array.isArray", "Array.of", "Array.prototype.fill", "Element.prototype.classList", "Event", "CustomEvent", "Event.focusin", "Event.hashchange", "Function.prototype.bind", "Map", "Object.assign", "Object.defineProperties", "Object.create", "Set", "_ArrayIterator", "_DOMTokenList", "DOMTokenList", "Symbol", "Symbol.iterator", "Symbol.species", "_Iterator", "Object.setPrototypeOf", "Symbol.toStringTag")
    • Function.prototype.bind, License: MIT (required by "default", "Object.getOwnPropertyDescriptor", "Array.from", "Object.assign", "_Iterator", "_ArrayIterator")
    • Object.getOwnPropertyDescriptor, License: CC0 (required by "default", "Array.from", "Object.assign", "Symbol", "Map", "Set", "Object.setPrototypeOf", "_ArrayIterator")
    • Object.keys, License: MIT (required by "default", "Object.assign", "Symbol", "Map", "Set")
    • Object.assign, License: CC0 (required by "default", "_Iterator", "_ArrayIterator", "Array.from")
    • Object.defineProperties, License: CC0 (required by "default", "Object.create", "Map", "URL", "location.origin", "_Iterator", "_ArrayIterator", "Array.from")
    • Array.prototype.forEach, License: CC0 (required by "default", "URL", "Symbol", "Map", "Set", "Object.setPrototypeOf", "_ArrayIterator", "Array.from")
    • Array.prototype.filter, License: CC0 (required by "default", "Symbol", "Map", "Set")
    • Array.prototype.map, License: CC0 (required by "default", "Symbol", "Map", "Set")
    • Object.create, License: CC0 (required by "default", "Map", "_ArrayIterator", "Array.from", "Symbol", "Set", "Object.setPrototypeOf")
    • Object.getOwnPropertyNames, License: CC0 (required by "default", "Symbol", "Map", "Set", "Object.setPrototypeOf", "_ArrayIterator", "Array.from")
    • Object.freeze, License: CC0 (required by "Symbol", "Map", "default", "Set")
    • Symbol, License: MIT (required by "Map", "default", "Set", "Symbol.iterator", "Symbol.species", "_Iterator", "_ArrayIterator", "Array.from", "Symbol.toStringTag")
    • Symbol.iterator, License: MIT (required by "Map", "default", "Set", "_Iterator", "_ArrayIterator", "Array.from")
    • Symbol.toStringTag, License: MIT (required by "_Iterator", "_ArrayIterator", "Array.from", "default")
    • _Iterator, License: MIT (required by "_ArrayIterator", "Array.from", "default")
    • Object.getPrototypeOf, License: CC0 (required by "default", "Map", "Object.setPrototypeOf", "_ArrayIterator", "Array.from")
    • Object.setPrototypeOf, License: MIT (required by "_ArrayIterator", "Array.from", "default")
    • String.prototype.includes, License: CC0 (required by "default", "String.prototype.contains", "_ArrayIterator", "Array.from")
    • String.prototype.contains, License: CC0 (required by "_ArrayIterator", "Array.from", "default")
    • _ArrayIterator, License: MIT (required by "Array.from", "default")
    • Array.isArray, License: CC0 (required by "default", "Array.from", "Map")
    • Number.isFinite, License: MIT (required by "Array.from", "default")
    • Number.isNaN, License: MIT (required by "default", "Array.from", "Map", "Set")
    • Array.from, License: CC0 (required by "default")
    • Array.of, License: MIT (required by "default")
    • Array.prototype.every, License: CC0 (required by "default")
    • Array.prototype.fill, License: CC0 (required by "default")
    • Array.prototype.indexOf, License: CC0 (required by "default", "Element.prototype.after", "Element.prototype.before", "Map", "Set")
    • Array.prototype.lastIndexOf, License: CC0 (required by "default")
    • Array.prototype.reduce, License: CC0 (required by "default")
    • Array.prototype.reduceRight, License: CC0 (required by "default")
    • Array.prototype.some, License: CC0 (required by "default")
    • Window, License: CC0 (required by "default", "Event", "CustomEvent", "Event.focusin", "Event.hashchange")
    • Document, License: CC0 (required by "default", "DocumentFragment.prototype.append", "DocumentFragment.prototype.prepend", "Element.prototype.after", "Element.prototype.append", "Element.prototype.before", "Element.prototype.prepend", "Element.prototype.remove", "Element.prototype.replaceWith", "Element", "Element.prototype.classList", "Element.prototype.cloneNode", "Element.prototype.matches", "Element.prototype.closest", "Event", "CustomEvent", "Event.focusin", "Event.hashchange", "document.querySelector", "~html5-elements", "_mutation")
    • Element, License: CC0 (required by "default", "DocumentFragment.prototype.append", "DocumentFragment.prototype.prepend", "Element.prototype.after", "Element.prototype.append", "Element.prototype.before", "Element.prototype.classList", "Element.prototype.cloneNode", "Element.prototype.matches", "Element.prototype.closest", "Element.prototype.prepend", "Element.prototype.remove", "Element.prototype.replaceWith", "Event", "CustomEvent", "Event.focusin", "Event.hashchange", "Node.prototype.contains", "document.querySelector", "_mutation")
    • Event, License: CC0 (required by "default", "CustomEvent", "Event.focusin", "Event.hashchange", "XMLHttpRequest")
    • CustomEvent, License: CC0 (required by "default", "document.visibilityState")
    • _DOMTokenList, License: ISC (required by "DOMTokenList", "default")
    • DOMTokenList, License: CC0 (required by "default", "Element.prototype.classList")
    • Date.now, License: CC0 (required by "default", "requestAnimationFrame", "performance.now")
    • Date.prototype.toISOString, License: CC0 (required by "default")
    • DocumentFragment, License: CC0 (required by "DocumentFragment.prototype.append", "default", "DocumentFragment.prototype.prepend")
    • _mutation, License: CC0 (required by "DocumentFragment.prototype.append", "default", "DocumentFragment.prototype.prepend", "Element.prototype.after", "Element.prototype.append", "Element.prototype.before", "Element.prototype.prepend", "Element.prototype.remove", "Element.prototype.replaceWith")
    • DocumentFragment.prototype.append, License: CC0 (required by "default")
    • DocumentFragment.prototype.prepend, License: CC0 (required by "default")
    • Element.prototype.after, License: CC0 (required by "default")
    • Element.prototype.append, License: CC0 (required by "default")
    • Element.prototype.before, License: CC0 (required by "default")
    • Element.prototype.classList, License: ISC (required by "default")
    • Element.prototype.cloneNode, License: CC0 (required by "default")
    • document.querySelector, License: CC0 (required by "default", "Element.prototype.matches", "Element.prototype.closest")
    • Element.prototype.matches, License: CC0 (required by "default", "Element.prototype.closest")
    • Element.prototype.closest, License: CC0 (required by "default")
    • Element.prototype.prepend, License: CC0 (required by "default")
    • Element.prototype.remove, License: CC0 (required by "default")
    • Element.prototype.replaceWith, License: CC0 (required by "default")
    • Event.focusin, License: CC0 (required by "default")
    • Event.hashchange, License: CC0 (required by "default")
    • JSON, License: MIT (required by "default")
    • Symbol.species, License: MIT (required by "Map", "default", "Set")
    • Map, License: CC0 (required by "default")
    • Node.prototype.contains, License: CC0 (required by "default")
    • Promise, License: MIT (required by "default")
    • Set, License: CC0 (required by "default")
    • String.prototype.endsWith, License: CC0 (required by "default")
    • String.prototype.startsWith, License: CC0 (required by "default")
    • String.prototype.trim, License: CC0 (required by "default")
    • URL, License: CC0 (required by "default")
    • XMLHttpRequest, License: CC0 (required by "default")
    • atob, License: MIT (required by "default")
    • document.visibilityState, License: CC0 (required by "default")
    • location.origin, License: CC0 (required by "default")
    • performance.now, License: CC0 (required by "requestAnimationFrame", "default")
    • requestAnimationFrame, License: MIT (required by "default")
    • ~html5-elements, License: MIT (required by "default")

This actually breaks some sites that would otherwise work fine with this browser.

Details

I would expect this service to not only correctly detect Waterfox/56, but also treat it like a Firefox/56 fork, not as a totally unknown browser from the dark ages.

Steps to reproduce:

Expected: The page should be overlayed with an getting-started information inline popup.
Actual: The popup does not appear in Waterfox, but, for instance, in Firefox 56.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.