Gitweb links:

...log 
http://git.netsurf-browser.org/netsurf.git/shortlog/6f99d28488c0eb39722079340864563318c7ef6b
...commit 
http://git.netsurf-browser.org/netsurf.git/commit/6f99d28488c0eb39722079340864563318c7ef6b
...tree 
http://git.netsurf-browser.org/netsurf.git/tree/6f99d28488c0eb39722079340864563318c7ef6b

The branch, master has been updated
       via  6f99d28488c0eb39722079340864563318c7ef6b (commit)
      from  230aa1736ff7e2aa77a5fc4fce55f5b048f9a9e4 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commitdiff 
http://git.netsurf-browser.org/netsurf.git/commit/?id=6f99d28488c0eb39722079340864563318c7ef6b
commit 6f99d28488c0eb39722079340864563318c7ef6b
Author: John-Mark Bell <[email protected]>
Commit: John-Mark Bell <[email protected]>

    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).

diff --git a/Makefile.defaults b/Makefile.defaults
index edf491a..85be748 100644
--- a/Makefile.defaults
+++ b/Makefile.defaults
@@ -101,10 +101,11 @@ NETSURF_USE_UTF8PROC := YES
 # Valid options: YES, NO
 NETSURF_STRIP_BINARY := NO
 
-# Template used for constructing the User Agent: string.  The first two
-# replacements are major/minor version, next is OS.
-# Please don't be tempted to mention Mozilla here!  Let's let that lie die.
-NETSURF_UA_FORMAT_STRING := "NetSurf/%d.%d (%s)"
+# Template used for constructing the User Agent: string.  The first
+# replacement is OS, the next two are major/minor version.
+# Note that the "Mozilla/5.0" prefix is a requirement to enable modern
+# web standards on many websites. It should not be removed or modified.
+NETSURF_UA_FORMAT_STRING := "Mozilla/5.0 (%s) NetSurf/%d.%d"
 
 # Default home page, if one is not defined by the user.  Note that this
 # option does not apply to the RISC OS version, as it has its own local
diff --git a/docs/PACKAGING-GTK b/docs/PACKAGING-GTK
index 4eab25b..b81bc61 100644
--- a/docs/PACKAGING-GTK
+++ b/docs/PACKAGING-GTK
@@ -64,18 +64,19 @@
 ===================
 
   You may also want to change NetSurf's user agent string to include the
-  name of your distribution.  The user agent string is build by a function
+  name of your distribution.  The user agent string is built by a function
   kept in utils/useragent.c - you'll want to change the macro called
   NETSURF_UA_FORMAT_STRING.  It's processed via sprintf, so keep that in
-  mind when changing it.  The first two printf parameters are major and minor
-  version numbers, the second two are OS name (uname -s) and architecture
-  (uname -m).  You might want change this to something like:
+  mind when changing it.  The first format parameter is the OS name (uname -s)
+  and the remainder are major and minor version numbers.  You might want
+  to change this to something like:
 
-      "NetSurf/%d.%d (%s; %s; Debian GNU/Linux)"
+      "Mozilla/5.0 (%s; Debian GNU/Linux) NetSurf/%d.%d"
 
-  or similar.  Please don't be tempted to mention Mozilla or similar - let's
-  let that lie die.
+  or similar.
 
+  Note that the "Mozilla/5.0" prefix is a requirement to enable modern
+  web standards on many websites. It should not be removed or modified.
 
   Home page URL
 ===============
diff --git a/utils/useragent.c b/utils/useragent.c
index 3d93a97..547999c 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;
 


-----------------------------------------------------------------------

Summary of changes:
 Makefile.defaults  |    9 +++++----
 docs/PACKAGING-GTK |   15 ++++++++-------
 utils/useragent.c  |   15 ++++++++++-----
 3 files changed, 23 insertions(+), 16 deletions(-)

diff --git a/Makefile.defaults b/Makefile.defaults
index edf491a..85be748 100644
--- a/Makefile.defaults
+++ b/Makefile.defaults
@@ -101,10 +101,11 @@ NETSURF_USE_UTF8PROC := YES
 # Valid options: YES, NO
 NETSURF_STRIP_BINARY := NO
 
-# Template used for constructing the User Agent: string.  The first two
-# replacements are major/minor version, next is OS.
-# Please don't be tempted to mention Mozilla here!  Let's let that lie die.
-NETSURF_UA_FORMAT_STRING := "NetSurf/%d.%d (%s)"
+# Template used for constructing the User Agent: string.  The first
+# replacement is OS, the next two are major/minor version.
+# Note that the "Mozilla/5.0" prefix is a requirement to enable modern
+# web standards on many websites. It should not be removed or modified.
+NETSURF_UA_FORMAT_STRING := "Mozilla/5.0 (%s) NetSurf/%d.%d"
 
 # Default home page, if one is not defined by the user.  Note that this
 # option does not apply to the RISC OS version, as it has its own local
diff --git a/docs/PACKAGING-GTK b/docs/PACKAGING-GTK
index 4eab25b..b81bc61 100644
--- a/docs/PACKAGING-GTK
+++ b/docs/PACKAGING-GTK
@@ -64,18 +64,19 @@
 ===================
 
   You may also want to change NetSurf's user agent string to include the
-  name of your distribution.  The user agent string is build by a function
+  name of your distribution.  The user agent string is built by a function
   kept in utils/useragent.c - you'll want to change the macro called
   NETSURF_UA_FORMAT_STRING.  It's processed via sprintf, so keep that in
-  mind when changing it.  The first two printf parameters are major and minor
-  version numbers, the second two are OS name (uname -s) and architecture
-  (uname -m).  You might want change this to something like:
+  mind when changing it.  The first format parameter is the OS name (uname -s)
+  and the remainder are major and minor version numbers.  You might want
+  to change this to something like:
 
-      "NetSurf/%d.%d (%s; %s; Debian GNU/Linux)"
+      "Mozilla/5.0 (%s; Debian GNU/Linux) NetSurf/%d.%d"
 
-  or similar.  Please don't be tempted to mention Mozilla or similar - let's
-  let that lie die.
+  or similar.
 
+  Note that the "Mozilla/5.0" prefix is a requirement to enable modern
+  web standards on many websites. It should not be removed or modified.
 
   Home page URL
 ===============
diff --git a/utils/useragent.c b/utils/useragent.c
index 3d93a97..547999c 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;
 


-- 
NetSurf Browser
_______________________________________________
netsurf-commits mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to