summaryrefslogtreecommitdiff
path: root/utils
diff options
context:
space:
mode:
authorJohn-Mark Bell <jmb@netsurf-browser.org>2022-05-21 16:30:25 +0100
committerJohn-Mark Bell <jmb@netsurf-browser.org>2022-05-27 21:47:02 +0100
commit6f99d28488c0eb39722079340864563318c7ef6b (patch)
tree509bf4c51c7f2ae6061515b3dda94410e359aa37 /utils
parent230aa1736ff7e2aa77a5fc4fce55f5b048f9a9e4 (diff)
downloadnetsurf-6f99d28488c0eb39722079340864563318c7ef6b.tar.gz
netsurf-6f99d28488c0eb39722079340864563318c7ef6b.tar.bz2
UA: align with compat spec
See: https://compat.spec.whatwg.org/#ua-string-section Force desktop sites on Linux by claiming to be running under X11 (Linux is otherwise considered a mobile OS).
Diffstat (limited to 'utils')
-rw-r--r--utils/useragent.c15
1 files changed, 10 insertions, 5 deletions
diff --git a/utils/useragent.c b/utils/useragent.c
index 3d93a97b2..547999c7c 100644
--- a/utils/useragent.c
+++ b/utils/useragent.c
@@ -19,6 +19,7 @@
#include <stdio.h>
#include <stdlib.h>
+#include <string.h>
#include "utils/config.h"
#include "utils/utsname.h"
@@ -29,7 +30,7 @@
static const char *core_user_agent_string = NULL;
#ifndef NETSURF_UA_FORMAT_STRING
-#define NETSURF_UA_FORMAT_STRING "NetSurf/%d.%d (%s)"
+#define NETSURF_UA_FORMAT_STRING "Mozilla/5.0 (%s) NetSurf/%d.%d"
#endif
/**
@@ -46,12 +47,16 @@ user_agent_build_string(void)
if (uname(&un) >= 0) {
sysname = un.sysname;
+ if (strcmp(sysname, "Linux") == 0) {
+ /* Force desktop, not mobile */
+ sysname = "X11; Linux";
+ }
}
len = snprintf(NULL, 0, NETSURF_UA_FORMAT_STRING,
+ sysname,
netsurf_version_major,
- netsurf_version_minor,
- sysname);
+ netsurf_version_minor);
ua_string = malloc(len + 1);
if (!ua_string) {
/** \todo this needs handling better */
@@ -59,9 +64,9 @@ user_agent_build_string(void)
}
snprintf(ua_string, len + 1,
NETSURF_UA_FORMAT_STRING,
+ sysname,
netsurf_version_major,
- netsurf_version_minor,
- sysname);
+ netsurf_version_minor);
core_user_agent_string = ua_string;