mirror of
https://github.com/faisalman/ua-parser-js.git
synced 2025-09-27 16:08:47 +03:00
Prevent altering the result when supplied user-agent is different from current user-agent
This commit is contained in:
parent
30de983043
commit
b09878934f
2
dist/ua-parser.min.js
vendored
2
dist/ua-parser.min.js
vendored
File diff suppressed because one or more lines are too long
2
dist/ua-parser.pack.js
vendored
2
dist/ua-parser.pack.js
vendored
File diff suppressed because one or more lines are too long
@ -477,7 +477,7 @@ http.createServer(function (req, res) {
|
|||||||
res.setHeader('Accept-CH', getHighEntropyValues);
|
res.setHeader('Accept-CH', getHighEntropyValues);
|
||||||
res.setHeader('Critical-CH', getHighEntropyValues);
|
res.setHeader('Critical-CH', getHighEntropyValues);
|
||||||
|
|
||||||
var ua = uap(req.headers);
|
var ua = uap(req.headers).withClientHints();
|
||||||
|
|
||||||
// END since@2.0 */
|
// END since@2.0 */
|
||||||
|
|
||||||
|
@ -932,26 +932,27 @@
|
|||||||
['data', createUAParserData(itemType, ua, rgxMap, uaCH)]
|
['data', createUAParserData(itemType, ua, rgxMap, uaCH)]
|
||||||
]);
|
]);
|
||||||
this.parse();
|
this.parse();
|
||||||
|
var isSelfNav = NAVIGATOR && NAVIGATOR.userAgent == ua;
|
||||||
switch(this.itemType) {
|
switch(this.itemType) {
|
||||||
case UA_BROWSER:
|
case UA_BROWSER:
|
||||||
// Brave-specific detection
|
// Brave-specific detection
|
||||||
if (NAVIGATOR && NAVIGATOR.userAgent == ua && NAVIGATOR.brave && typeof NAVIGATOR.brave.isBrave == FUNC_TYPE) {
|
if (isSelfNav && NAVIGATOR.brave && typeof NAVIGATOR.brave.isBrave == FUNC_TYPE) {
|
||||||
this.set(NAME, 'Brave');
|
this.set(NAME, 'Brave');
|
||||||
}
|
}
|
||||||
this.set(MAJOR, majorize(this.get(VERSION)));
|
this.set(MAJOR, majorize(this.get(VERSION)));
|
||||||
break;
|
break;
|
||||||
case UA_DEVICE:
|
case UA_DEVICE:
|
||||||
if (!this.get(TYPE) && NAVIGATOR_UADATA && NAVIGATOR_UADATA[MOBILE]) {
|
if (isSelfNav && !this.get(TYPE) && NAVIGATOR_UADATA && NAVIGATOR_UADATA[MOBILE]) {
|
||||||
this.set(TYPE, MOBILE);
|
this.set(TYPE, MOBILE);
|
||||||
}
|
}
|
||||||
// iPadOS-specific detection: identified as Mac, but has some iOS-only properties
|
// iPadOS-specific detection: identified as Mac, but has some iOS-only properties
|
||||||
if (this.get(MODEL) == 'Macintosh' && NAVIGATOR && typeof NAVIGATOR.standalone !== UNDEF_TYPE && NAVIGATOR.maxTouchPoints && NAVIGATOR.maxTouchPoints > 2) {
|
if (isSelfNav && this.get(MODEL) == 'Macintosh' && NAVIGATOR && typeof NAVIGATOR.standalone !== UNDEF_TYPE && NAVIGATOR.maxTouchPoints && NAVIGATOR.maxTouchPoints > 2) {
|
||||||
this.set(MODEL, 'iPad')
|
this.set(MODEL, 'iPad')
|
||||||
.set(TYPE, TABLET);
|
.set(TYPE, TABLET);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case UA_OS:
|
case UA_OS:
|
||||||
if (!this.get(NAME) && NAVIGATOR_UADATA && NAVIGATOR_UADATA[PLATFORM] && NAVIGATOR_UADATA[PLATFORM] != 'Unknown') {
|
if (isSelfNav && !this.get(NAME) && NAVIGATOR_UADATA && NAVIGATOR_UADATA[PLATFORM]) {
|
||||||
this.set(NAME, NAVIGATOR_UADATA[PLATFORM]);
|
this.set(NAME, NAVIGATOR_UADATA[PLATFORM]);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -936,26 +936,27 @@ const window = undefined;
|
|||||||
['data', createUAParserData(itemType, ua, rgxMap, uaCH)]
|
['data', createUAParserData(itemType, ua, rgxMap, uaCH)]
|
||||||
]);
|
]);
|
||||||
this.parse();
|
this.parse();
|
||||||
|
var isSelfNav = NAVIGATOR && NAVIGATOR.userAgent == ua;
|
||||||
switch(this.itemType) {
|
switch(this.itemType) {
|
||||||
case UA_BROWSER:
|
case UA_BROWSER:
|
||||||
// Brave-specific detection
|
// Brave-specific detection
|
||||||
if (NAVIGATOR && NAVIGATOR.userAgent == ua && NAVIGATOR.brave && typeof NAVIGATOR.brave.isBrave == FUNC_TYPE) {
|
if (isSelfNav && NAVIGATOR.brave && typeof NAVIGATOR.brave.isBrave == FUNC_TYPE) {
|
||||||
this.set(NAME, 'Brave');
|
this.set(NAME, 'Brave');
|
||||||
}
|
}
|
||||||
this.set(MAJOR, majorize(this.get(VERSION)));
|
this.set(MAJOR, majorize(this.get(VERSION)));
|
||||||
break;
|
break;
|
||||||
case UA_DEVICE:
|
case UA_DEVICE:
|
||||||
if (!this.get(TYPE) && NAVIGATOR_UADATA && NAVIGATOR_UADATA[MOBILE]) {
|
if (isSelfNav && !this.get(TYPE) && NAVIGATOR_UADATA && NAVIGATOR_UADATA[MOBILE]) {
|
||||||
this.set(TYPE, MOBILE);
|
this.set(TYPE, MOBILE);
|
||||||
}
|
}
|
||||||
// iPadOS-specific detection: identified as Mac, but has some iOS-only properties
|
// iPadOS-specific detection: identified as Mac, but has some iOS-only properties
|
||||||
if (this.get(MODEL) == 'Macintosh' && NAVIGATOR && typeof NAVIGATOR.standalone !== UNDEF_TYPE && NAVIGATOR.maxTouchPoints && NAVIGATOR.maxTouchPoints > 2) {
|
if (isSelfNav && this.get(MODEL) == 'Macintosh' && NAVIGATOR && typeof NAVIGATOR.standalone !== UNDEF_TYPE && NAVIGATOR.maxTouchPoints && NAVIGATOR.maxTouchPoints > 2) {
|
||||||
this.set(MODEL, 'iPad')
|
this.set(MODEL, 'iPad')
|
||||||
.set(TYPE, TABLET);
|
.set(TYPE, TABLET);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case UA_OS:
|
case UA_OS:
|
||||||
if (!this.get(NAME) && NAVIGATOR_UADATA && NAVIGATOR_UADATA[PLATFORM] && NAVIGATOR_UADATA[PLATFORM] != 'Unknown') {
|
if (isSelfNav && !this.get(NAME) && NAVIGATOR_UADATA && NAVIGATOR_UADATA[PLATFORM]) {
|
||||||
this.set(NAME, NAVIGATOR_UADATA[PLATFORM]);
|
this.set(NAME, NAVIGATOR_UADATA[PLATFORM]);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user