@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Make User-Agent regex detect Firefox on Android

Summary:
Set the `device-phone` CSS class also for Firefox on Android to (hopefully) avoid or decrease large layout shifts.
See https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Headers/User-Agent/Firefox

Closes T16071

Test Plan:
Check if the given regex matches User-Agent strings.

Also, emulate a desktop and a mobile visit with cURL, and check their HTML body CSS classes:

lang=bash
curl --silent --user-agent "Mozilla/5.0 (X11; Linux x86_64; rv:128.0) Gecko/20100101 Firefox/128.0" http://phorge.localhost | grep -Po '<body class=".*?"'
curl --silent --user-agent "Mozilla/5.0 (Android 11; Mobile; rv:138.0) Gecko/138.0 Firefox/138.0" http://phorge.localhost | grep -Po '<body class=".*?"'

Output before the change, observe that the second line is recognized as desktop by mistake:

lang=html,counterexample
<body class="device-desktop platform-linux phui-theme-blindigo phabricator-home"
<body class="device-desktop phui-theme-blindigo phabricator-home"

Output after the change, observe that the second line is finally recognized as mobile:

lang=html
<body class="device-desktop platform-linux phui-theme-blindigo phabricator-home"
<body class="device-phone device phui-theme-blindigo phabricator-home"

Reviewers: O1 Blessed Committers, valerio.bozzolan

Reviewed By: O1 Blessed Committers, valerio.bozzolan

Subscribers: tobiaswiese, valerio.bozzolan, Matthew, Cigaryno

Maniphest Tasks: T16071

Differential Revision: https://we.phorge.it/D26021

+2 -2
+2 -2
src/view/page/PhabricatorStandardPageView.php
··· 627 627 // of incorrectly-styled content. 628 628 $device_guess = 'device-desktop'; 629 629 if (phutil_nonempty_string($agent)) { 630 - if (preg_match('@iPhone|iPod|(Android.*Chrome/[.0-9]* Mobile)@', 631 - $agent)) { 630 + if (preg_match('@iPhone|iPod|Android.*(Chrome/[.0-9]* Mobile|'. 631 + 'Mobile.*Firefox/[.0-9]*)@', $agent)) { 632 632 $device_guess = 'device-phone device'; 633 633 } else if (preg_match('@iPad|(Android.*Chrome/)@', $agent)) { 634 634 $device_guess = 'device-tablet device';