Fossil SCM

Disable the mouse-motion anti-robot requirement for devices that self-identify as a tablet or mobile device, and hence might never send mouse-motion events.

drh 2019-06-10 04:48 trunk
Commit 60d25189d2718a5a6c771046ca22d25dd438ae40633c0eeda6710c3fceeebc65
+1 -3
--- src/href.js
+++ src/href.js
@@ -31,13 +31,11 @@
3131
}
3232
function antiRobotDefense(){
3333
var x = document.getElementById("href-data");
3434
var jx = x.textContent || x.innerText;
3535
var g = JSON.parse(jx);
36
- var isOperaMini =
37
- Object.prototype.toString.call(window.operamini)==="[object OperaMini]";
38
- if(g.mouseover && !isOperaMini){
36
+ if(g.mouseover){
3937
document.getElementsByTagName("body")[0].onmousemove=function(){
4038
setTimeout(setAllHrefs, g.delay);
4139
}
4240
}else{
4341
setTimeout(setAllHrefs, g.delay);
4442
--- src/href.js
+++ src/href.js
@@ -31,13 +31,11 @@
31 }
32 function antiRobotDefense(){
33 var x = document.getElementById("href-data");
34 var jx = x.textContent || x.innerText;
35 var g = JSON.parse(jx);
36 var isOperaMini =
37 Object.prototype.toString.call(window.operamini)==="[object OperaMini]";
38 if(g.mouseover && !isOperaMini){
39 document.getElementsByTagName("body")[0].onmousemove=function(){
40 setTimeout(setAllHrefs, g.delay);
41 }
42 }else{
43 setTimeout(setAllHrefs, g.delay);
44
--- src/href.js
+++ src/href.js
@@ -31,13 +31,11 @@
31 }
32 function antiRobotDefense(){
33 var x = document.getElementById("href-data");
34 var jx = x.textContent || x.innerText;
35 var g = JSON.parse(jx);
36 if(g.mouseover){
 
 
37 document.getElementsByTagName("body")[0].onmousemove=function(){
38 setTimeout(setAllHrefs, g.delay);
39 }
40 }else{
41 setTimeout(setAllHrefs, g.delay);
42
+19 -3
--- src/login.c
+++ src/login.c
@@ -444,10 +444,21 @@
444444
if( strncmp(zAgent, "Safari/", 7)==0 ) return 1;
445445
if( strncmp(zAgent, "Lynx/", 5)==0 ) return 1;
446446
if( strncmp(zAgent, "NetSurf/", 8)==0 ) return 1;
447447
return 0;
448448
}
449
+
450
+/*
451
+** Look at the HTTP_USER_AGENT parameter and try to determine if the user agent
452
+** is a mobile device that does not normally have a mouse.
453
+*/
454
+static int isMobile(const char *zAgent){
455
+ if( sqlite3_strglob("*Mobile/*", zAgent)==0 ) return 1;
456
+ if( sqlite3_strglob("*Tablet;*", zAgent)==0 ) return 1;
457
+ return 0;
458
+}
459
+
449460
450461
/*
451462
** COMMAND: test-ishuman
452463
**
453464
** Read lines of text from standard input. Interpret each line of text
@@ -1112,14 +1123,19 @@
11121123
if( fossil_strcmp(g.zLogin,"nobody")==0 ){
11131124
g.zLogin = 0;
11141125
}
11151126
if( PB("isrobot") ){
11161127
g.isHuman = 0;
1117
- }else if( g.zLogin==0 ){
1118
- g.isHuman = isHuman(P("HTTP_USER_AGENT"));
1128
+ g.isMobile = 0;
11191129
}else{
1120
- g.isHuman = 1;
1130
+ const char *zAgent = P("HTTP_USER_AGENT");
1131
+ if( g.zLogin==0 ){
1132
+ g.isHuman = isHuman(zAgent);
1133
+ }else{
1134
+ g.isHuman = 1;
1135
+ }
1136
+ g.isMobile = isMobile(zAgent);
11211137
}
11221138
11231139
/* Set the capabilities */
11241140
login_replace_capabilities(zCap, 0);
11251141
11261142
--- src/login.c
+++ src/login.c
@@ -444,10 +444,21 @@
444 if( strncmp(zAgent, "Safari/", 7)==0 ) return 1;
445 if( strncmp(zAgent, "Lynx/", 5)==0 ) return 1;
446 if( strncmp(zAgent, "NetSurf/", 8)==0 ) return 1;
447 return 0;
448 }
 
 
 
 
 
 
 
 
 
 
 
449
450 /*
451 ** COMMAND: test-ishuman
452 **
453 ** Read lines of text from standard input. Interpret each line of text
@@ -1112,14 +1123,19 @@
1112 if( fossil_strcmp(g.zLogin,"nobody")==0 ){
1113 g.zLogin = 0;
1114 }
1115 if( PB("isrobot") ){
1116 g.isHuman = 0;
1117 }else if( g.zLogin==0 ){
1118 g.isHuman = isHuman(P("HTTP_USER_AGENT"));
1119 }else{
1120 g.isHuman = 1;
 
 
 
 
 
 
1121 }
1122
1123 /* Set the capabilities */
1124 login_replace_capabilities(zCap, 0);
1125
1126
--- src/login.c
+++ src/login.c
@@ -444,10 +444,21 @@
444 if( strncmp(zAgent, "Safari/", 7)==0 ) return 1;
445 if( strncmp(zAgent, "Lynx/", 5)==0 ) return 1;
446 if( strncmp(zAgent, "NetSurf/", 8)==0 ) return 1;
447 return 0;
448 }
449
450 /*
451 ** Look at the HTTP_USER_AGENT parameter and try to determine if the user agent
452 ** is a mobile device that does not normally have a mouse.
453 */
454 static int isMobile(const char *zAgent){
455 if( sqlite3_strglob("*Mobile/*", zAgent)==0 ) return 1;
456 if( sqlite3_strglob("*Tablet;*", zAgent)==0 ) return 1;
457 return 0;
458 }
459
460
461 /*
462 ** COMMAND: test-ishuman
463 **
464 ** Read lines of text from standard input. Interpret each line of text
@@ -1112,14 +1123,19 @@
1123 if( fossil_strcmp(g.zLogin,"nobody")==0 ){
1124 g.zLogin = 0;
1125 }
1126 if( PB("isrobot") ){
1127 g.isHuman = 0;
1128 g.isMobile = 0;
 
1129 }else{
1130 const char *zAgent = P("HTTP_USER_AGENT");
1131 if( g.zLogin==0 ){
1132 g.isHuman = isHuman(zAgent);
1133 }else{
1134 g.isHuman = 1;
1135 }
1136 g.isMobile = isMobile(zAgent);
1137 }
1138
1139 /* Set the capabilities */
1140 login_replace_capabilities(zCap, 0);
1141
1142
+1
--- src/main.c
+++ src/main.c
@@ -203,10 +203,11 @@
203203
** SSL client identity */
204204
int useLocalauth; /* No login required if from 127.0.0.1 */
205205
int noPswd; /* Logged in without password (on 127.0.0.1) */
206206
int userUid; /* Integer user id */
207207
int isHuman; /* True if access by a human, not a spider or bot */
208
+ int isMobile; /* Human user on a mobile device w/o a mouse */
208209
int comFmtFlags; /* Zero or more "COMMENT_PRINT_*" bit flags, should be
209210
** accessed through get_comment_format(). */
210211
211212
/* Information used to populate the RCVFROM table */
212213
int rcvid; /* The rcvid. 0 if not yet defined. */
213214
--- src/main.c
+++ src/main.c
@@ -203,10 +203,11 @@
203 ** SSL client identity */
204 int useLocalauth; /* No login required if from 127.0.0.1 */
205 int noPswd; /* Logged in without password (on 127.0.0.1) */
206 int userUid; /* Integer user id */
207 int isHuman; /* True if access by a human, not a spider or bot */
 
208 int comFmtFlags; /* Zero or more "COMMENT_PRINT_*" bit flags, should be
209 ** accessed through get_comment_format(). */
210
211 /* Information used to populate the RCVFROM table */
212 int rcvid; /* The rcvid. 0 if not yet defined. */
213
--- src/main.c
+++ src/main.c
@@ -203,10 +203,11 @@
203 ** SSL client identity */
204 int useLocalauth; /* No login required if from 127.0.0.1 */
205 int noPswd; /* Logged in without password (on 127.0.0.1) */
206 int userUid; /* Integer user id */
207 int isHuman; /* True if access by a human, not a spider or bot */
208 int isMobile; /* Human user on a mobile device w/o a mouse */
209 int comFmtFlags; /* Zero or more "COMMENT_PRINT_*" bit flags, should be
210 ** accessed through get_comment_format(). */
211
212 /* Information used to populate the RCVFROM table */
213 int rcvid; /* The rcvid. 0 if not yet defined. */
214
+2 -1
--- src/style.c
+++ src/style.c
@@ -665,11 +665,12 @@
665665
*/
666666
static void style_load_all_js_files(void){
667667
int i;
668668
if( needHrefJs ){
669669
int nDelay = db_get_int("auto-hyperlink-delay",0);
670
- int bMouseover = db_get_boolean("auto-hyperlink-mouseover",0);
670
+ int bMouseover =
671
+ !g.isMobile && db_get_boolean("auto-hyperlink-mouseover",0);
671672
@ <script id='href-data' type='application/json'>\
672673
@ {"delay":%d(nDelay),"mouseover":%d(bMouseover)}</script>
673674
}
674675
@ <script nonce="%h(style_nonce())">
675676
@ function debugMsg(msg){
676677
--- src/style.c
+++ src/style.c
@@ -665,11 +665,12 @@
665 */
666 static void style_load_all_js_files(void){
667 int i;
668 if( needHrefJs ){
669 int nDelay = db_get_int("auto-hyperlink-delay",0);
670 int bMouseover = db_get_boolean("auto-hyperlink-mouseover",0);
 
671 @ <script id='href-data' type='application/json'>\
672 @ {"delay":%d(nDelay),"mouseover":%d(bMouseover)}</script>
673 }
674 @ <script nonce="%h(style_nonce())">
675 @ function debugMsg(msg){
676
--- src/style.c
+++ src/style.c
@@ -665,11 +665,12 @@
665 */
666 static void style_load_all_js_files(void){
667 int i;
668 if( needHrefJs ){
669 int nDelay = db_get_int("auto-hyperlink-delay",0);
670 int bMouseover =
671 !g.isMobile && db_get_boolean("auto-hyperlink-mouseover",0);
672 @ <script id='href-data' type='application/json'>\
673 @ {"delay":%d(nDelay),"mouseover":%d(bMouseover)}</script>
674 }
675 @ <script nonce="%h(style_nonce())">
676 @ function debugMsg(msg){
677

Keyboard Shortcuts

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