Bug 209378 - [GTK] Add user agent quirk for auth.mayohr.com
Summary: [GTK] Add user agent quirk for auth.mayohr.com
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebKitGTK (show other bugs)
Version: WebKit Local Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Nobody
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-03-21 10:57 PDT by Ting-Wei Lan
Modified: 2020-03-25 06:54 PDT (History)
3 users (show)

See Also:


Attachments
Patch (6.99 KB, patch)
2020-03-21 10:59 PDT, Ting-Wei Lan
no flags Details | Formatted Diff | Diff
Patch (6.98 KB, patch)
2020-03-21 11:42 PDT, Ting-Wei Lan
no flags Details | Formatted Diff | Diff
Patch (5.95 KB, patch)
2020-03-24 21:20 PDT, Ting-Wei Lan
no flags Details | Formatted Diff | Diff
Patch (5.94 KB, patch)
2020-03-25 04:34 PDT, Ting-Wei Lan
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 2020-03-21 10:57:04 PDT
This site blocks the login page completely and asks the user to download Google Chrome when using our standard user agent. It only blocks the login page. After logging in, it works fine without user agent quirks.

I added a new quirk called 'NeedsNoSafariVersion' for it because the site still blocks the page if both 'Chrome/' and 'Version/' exist in the user agent string. Therefore, I need a way to not only add 'Chrome/' but also remove 'Version/'.
Comment 1 Ting-Wei Lan 2020-03-21 10:59:48 PDT
Created attachment 394169 [details]
Patch
Comment 2 Ting-Wei Lan 2020-03-21 11:42:06 PDT
Created attachment 394171 [details]
Patch
Comment 3 Michael Catanzaro 2020-03-23 07:30:58 PDT
Comment on attachment 394171 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=394171&action=review

OK this looks basically good, but let's simplify it a bit, because it reveals a problem with our existing Chrome quirk.

> Source/WebCore/platform/UserAgentQuirks.cpp:157
> +    // This site does not recognize Chrome/X with Version/X as a valid Chrome
> +    // user agent, so we have to hide Version/X from the user agent.

OK, this just indicates that our current Google Chrome quirk is broken, and we just got lucky that the existing sites we use it on didn't notice. We don't need a new quirk here; instead, we should fix the existing quirk to not include Version/X.

> Source/WebCore/platform/glib/UserAgentGLib.cpp:113
>      // Version/X is mandatory *before* Safari/X to be a valid Safari UA. See
>      // https://bugs.webkit.org/show_bug.cgi?id=133403 for details.
> -    uaString.appendLiteral("Version/13.0 Safari/");
> +    if (!quirks.contains(UserAgentQuirks::NeedsNoSafariVersion))
> +        uaString.appendLiteral("Version/13.0 ");

So this can become an else clause of the previous condition. Then it will get added except when the Chrome quirk is in use. (Or when the Firefox quirk is in use, but we already returned early up above in that case.)
Comment 4 Ting-Wei Lan 2020-03-24 21:20:34 PDT
Created attachment 394469 [details]
Patch
Comment 5 Ting-Wei Lan 2020-03-25 04:34:55 PDT
Created attachment 394482 [details]
Patch
Comment 6 Ting-Wei Lan 2020-03-25 06:22:12 PDT
I haven't figured out how to run WebKit tests, so I don't know if the test I modified in the patch passes.
Comment 7 EWS 2020-03-25 06:54:21 PDT
Committed r258978: <https://trac.webkit.org/changeset/258978>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 394482 [details].