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

drh 2021-03-01 20:54 trunk
Commit 4de677dcc3e61228a1128759892d12998bdb300e4b169b80cd2fbd0fe3a281a3
1 file changed +5 -4
+5 -4
--- src/login.c
+++ src/login.c
@@ -433,18 +433,19 @@
433433
** Make a guess at whether or not the requestor is a mobile device or
434434
** a desktop device (narrow screen vs. wide screen) based the HTTP_USER_AGENT
435435
** parameter. Return true for mobile and false for desktop.
436436
**
437437
** 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
438442
*/
439443
int user_agent_is_likely_mobile(void){
440444
const char *zAgent = P("HTTP_USER_AGENT");
441445
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;
446447
return 0;
447448
}
448449
449450
/*
450451
** COMMAND: test-ishuman
451452
--- 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

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button