Fossil SCM
Change the algorithm for detecting when a user agent is a narrow-screen mobile device to the algorithm recommanded at [https://developer.mozilla.org/en-US/docs/Web/HTTP/Browser_detection_using_the_user_agent#mobile_device_detection].
Commit
4de677dcc3e61228a1128759892d12998bdb300e4b169b80cd2fbd0fe3a281a3
Parent
29bab2748bdb775…
1 file changed
+5
-4
+5
-4
| --- src/login.c | ||
| +++ src/login.c | ||
| @@ -433,18 +433,19 @@ | ||
| 433 | 433 | ** Make a guess at whether or not the requestor is a mobile device or |
| 434 | 434 | ** a desktop device (narrow screen vs. wide screen) based the HTTP_USER_AGENT |
| 435 | 435 | ** parameter. Return true for mobile and false for desktop. |
| 436 | 436 | ** |
| 437 | 437 | ** Caution: This is only a guess. |
| 438 | +** | |
| 439 | +** Algorithm derived from https://developer.mozilla.org/en-US/docs/Web/ | |
| 440 | +** HTTP/Browser_detection_using_the_user_agent#mobile_device_detection on | |
| 441 | +** 2021-03-01 | |
| 438 | 442 | */ |
| 439 | 443 | int user_agent_is_likely_mobile(void){ |
| 440 | 444 | const char *zAgent = P("HTTP_USER_AGENT"); |
| 441 | 445 | if( zAgent==0 ) return 0; |
| 442 | - if( sqlite3_strglob("*droid*", zAgent)==0 ) return 1; | |
| 443 | - if( sqlite3_strglob("*mobile*", zAgent)==0 ) return 1; | |
| 444 | - if( sqlite3_strglob("*iOS*", zAgent)==0 ) return 1; | |
| 445 | - if( sqlite3_strglob("*iPhone*", zAgent)==0 ) return 1; | |
| 446 | + if( strstr(zAgent,"Mobi")!=0 ) return 1; | |
| 446 | 447 | return 0; |
| 447 | 448 | } |
| 448 | 449 | |
| 449 | 450 | /* |
| 450 | 451 | ** COMMAND: test-ishuman |
| 451 | 452 |
| --- src/login.c | |
| +++ src/login.c | |
| @@ -433,18 +433,19 @@ | |
| 433 | ** Make a guess at whether or not the requestor is a mobile device or |
| 434 | ** a desktop device (narrow screen vs. wide screen) based the HTTP_USER_AGENT |
| 435 | ** parameter. Return true for mobile and false for desktop. |
| 436 | ** |
| 437 | ** Caution: This is only a guess. |
| 438 | */ |
| 439 | int user_agent_is_likely_mobile(void){ |
| 440 | const char *zAgent = P("HTTP_USER_AGENT"); |
| 441 | if( zAgent==0 ) return 0; |
| 442 | if( sqlite3_strglob("*droid*", zAgent)==0 ) return 1; |
| 443 | if( sqlite3_strglob("*mobile*", zAgent)==0 ) return 1; |
| 444 | if( sqlite3_strglob("*iOS*", zAgent)==0 ) return 1; |
| 445 | if( sqlite3_strglob("*iPhone*", zAgent)==0 ) return 1; |
| 446 | return 0; |
| 447 | } |
| 448 | |
| 449 | /* |
| 450 | ** COMMAND: test-ishuman |
| 451 |
| --- src/login.c | |
| +++ src/login.c | |
| @@ -433,18 +433,19 @@ | |
| 433 | ** Make a guess at whether or not the requestor is a mobile device or |
| 434 | ** a desktop device (narrow screen vs. wide screen) based the HTTP_USER_AGENT |
| 435 | ** parameter. Return true for mobile and false for desktop. |
| 436 | ** |
| 437 | ** Caution: This is only a guess. |
| 438 | ** |
| 439 | ** Algorithm derived from https://developer.mozilla.org/en-US/docs/Web/ |
| 440 | ** HTTP/Browser_detection_using_the_user_agent#mobile_device_detection on |
| 441 | ** 2021-03-01 |
| 442 | */ |
| 443 | int user_agent_is_likely_mobile(void){ |
| 444 | const char *zAgent = P("HTTP_USER_AGENT"); |
| 445 | if( zAgent==0 ) return 0; |
| 446 | if( strstr(zAgent,"Mobi")!=0 ) return 1; |
| 447 | return 0; |
| 448 | } |
| 449 | |
| 450 | /* |
| 451 | ** COMMAND: test-ishuman |
| 452 |