Bug 209378

Summary: [GTK] Add user agent quirk for auth.mayohr.com
Product: WebKit Reporter: Ting-Wei Lan <lantw44>
Component: WebKitGTKAssignee: Nobody <webkit-unassigned>
Status: RESOLVED FIXED    
Severity: Normal CC: bugs-noreply, cgarcia, mcatanzaro
Priority: P2    
Version: WebKit Local Build   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
Patch
none
Patch
none
Patch
none
Patch none

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