Bug 199745 - [GTK] GitHub breaks on FreeBSD because of "unsupported browser"
Summary: [GTK] GitHub breaks on FreeBSD because of "unsupported browser"
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebKitGTK (show other bugs)
Version: WebKit Local Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Michael Catanzaro
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-07-11 21:13 PDT by Ting-Wei Lan
Modified: 2019-07-15 01:59 PDT (History)
4 users (show)

See Also:


Attachments
"Unsupported browser" (46.17 KB, image/png)
2019-07-11 21:13 PDT, Ting-Wei Lan
no flags Details
Patch (2.94 KB, patch)
2019-07-12 12:11 PDT, Michael Catanzaro
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Ting-Wei Lan 2019-07-11 21:13:38 PDT
Created attachment 373996 [details]
"Unsupported browser"

It looks like GitHub starts to disable features based on the user agent.

There are too many problems, making the site really hard to use.
1. Can't preview when writing a comment. The preview tab exists, but clicking it does nothing.
2. Can't edit a comment. The menu item exists, but clicking it does nothing as well.
3. 'Click for language details' still does nothing.
4. 'Switch branches or tags' shows an empty menu.
5. When it says it is loading somethings, it is likely that it won't load.
6. Authorizing an application to use your GitHub data is likely to be impossible because the button isn't clickable.
7. I even saw it removed indents once when viewing the code, but I don't know how to reproduce it.

It seems that a lot of these problems can be fixed by changing the user agent from FreeBSD to Linux:
gsettings set org.gnome.Epiphany.web:/org/gnome/epiphany/web/ user-agent 'Mozilla/5.0 (X11; Linux amd64) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/11.0 Safari/605.1.15 Epiphany/605.1.15'

The test was done on WebKitGTK 2.25.2. Are we going to need a user agent quirk for it?
Comment 1 Ting-Wei Lan 2019-07-11 21:36:53 PDT
In addition to replace FreeBSD with Linux in the user agent, it can also be fixed by putting both FreeBSD and Linux in the user agent.
gsettings set org.gnome.Epiphany.web:/org/gnome/epiphany/web/ user-agent 'Mozilla/5.0 (X11; FreeBSD amd64; Linux amd64) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/11.0 Safari/605.1.15 Epiphany/605.1.15'

It may look unusual, but FreeBSD already does it in its Chromium package. FreeBSD carries more than 700 patches for Chromium because Google doesn't accept patches for *BSD support. I guess it is done by this patch.
$ cat /usr/ports/www/chromium/files/patch-content_common_user__agent.cc 
--- content/common/user_agent.cc.orig	2019-03-11 22:00:58 UTC
+++ content/common/user_agent.cc
@@ -131,6 +131,14 @@ std::string BuildOSCpuInfo(bool include_android_build_
 #endif
   );  // NOLINT
 
+#if defined(OS_BSD)
+#if defined(__x86_64__)
+  base::StringAppendF(&os_cpu, "; Linux x86_64");
+#else
+  base::StringAppendF(&os_cpu, "; Linux i686");
+#endif
+#endif
+
   return os_cpu;
 }
Comment 2 Michael Catanzaro 2019-07-12 07:30:26 PDT
Could you try changing the Safari version to Version/12.0 or Version/12.1? The warning banner seems to indicate it's complaining about the Safari version.

I thought Safari version was going to be frozen in the UA so we wouldn't have to change that ever again. I'll ask around.
Comment 3 Michael Catanzaro 2019-07-12 07:40:16 PDT
Then again, if it doesn't complain about UAs with Version/11.0, that probably suggests we really have to use the Linux quirk. I'm willing to do that.

(In reply to Ting-Wei Lan from comment #1)
> In addition to replace FreeBSD with Linux in the user agent, it can also be
> fixed by putting both FreeBSD and Linux in the user agent.

I'd rather use our existing Linux x86_64 quirk, which will replace FreeBSD in the user agent. Only for those websites that really require it, of course.
Comment 4 Ting-Wei Lan 2019-07-12 07:44:54 PDT
(In reply to Michael Catanzaro from comment #2)
> Could you try changing the Safari version to Version/12.0 or Version/12.1?
> The warning banner seems to indicate it's complaining about the Safari
> version.

Yes, using Version/12.0 or Version/12.1 also fixes it.
Comment 5 Michael Catanzaro 2019-07-12 12:11:36 PDT
Created attachment 374027 [details]
Patch
Comment 6 Ting-Wei Lan 2019-07-14 01:58:17 PDT
(In reply to Michael Catanzaro from comment #5)
> Created attachment 374027 [details]
> Patch

Yes, it works for me.
Comment 7 WebKit Commit Bot 2019-07-15 01:58:58 PDT
Comment on attachment 374027 [details]
Patch

Clearing flags on attachment: 374027

Committed r247427: <https://trac.webkit.org/changeset/247427>
Comment 8 WebKit Commit Bot 2019-07-15 01:59:00 PDT
All reviewed patches have been landed.  Closing bug.