Fossil SCM

Do not show diffs on the /vinfo page unless we know that the client is not a robot.

drh 2025-08-19 16:02 trunk
Commit 3710202914e5ddd15f3844be5f116503cb6a5d26f83ef7c73cda80072e33fa08
1 file changed +25 -10
+25 -10
--- src/info.c
+++ src/info.c
@@ -1228,17 +1228,19 @@
12281228
append_file_change_line(zUuid, zName, zOld, zNew, zOldName,
12291229
pCfg,mperm);
12301230
}
12311231
db_finalize(&q3);
12321232
@ </div>
1233
- @ <script nonce='%h(style_nonce())'>;/* info.c:%d(__LINE__) */
1234
- @ document.getElementById('changes_section').textContent = 'Changes ' +
1235
- @ '(%d(g.diffCnt[0]) file' + (%d(g.diffCnt[0])===1 ? '' : 's') + ': ' +
1236
- @ '+%d(g.diffCnt[1]) ' +
1237
- @ '−%d(g.diffCnt[2]))'
1238
- @ </script>
1239
- append_diff_javascript(diffType);
1233
+ if( diffType!=0 ){
1234
+ @ <script nonce='%h(style_nonce())'>;/* info.c:%d(__LINE__) */
1235
+ @ document.getElementById('changes_section').textContent = 'Changes ' +
1236
+ @ '(%d(g.diffCnt[0]) file' + (%d(g.diffCnt[0])===1 ? '' : 's') + ': ' +
1237
+ @ '+%d(g.diffCnt[1]) ' +
1238
+ @ '−%d(g.diffCnt[2]))'
1239
+ @ </script>
1240
+ append_diff_javascript(diffType);
1241
+ }
12401242
style_finish_page();
12411243
}
12421244
12431245
/*
12441246
** WEBPAGE: winfo
@@ -1926,18 +1928,31 @@
19261928
** * The "preferred-diff-type" setting
19271929
** * 1 for mobile and 2 for desktop, based on the UserAgent
19281930
*/
19291931
int preferred_diff_type(void){
19301932
int dflt;
1933
+ int res;
1934
+ int isBot;
19311935
static char zDflt[2]
19321936
/*static b/c cookie_link_parameter() does not copy it!*/;
1933
- dflt = db_get_int("preferred-diff-type",-99);
1934
- if( dflt<=0 ) dflt = user_agent_is_likely_mobile() ? 1 : 2;
1937
+ if( client_might_be_a_robot() ){
1938
+ dflt = 0;
1939
+ isBot = 1;
1940
+ }else{
1941
+ dflt = db_get_int("preferred-diff-type",-99);
1942
+ if( dflt<=0 ) dflt = user_agent_is_likely_mobile() ? 1 : 2;
1943
+ isBot = 0;
1944
+ }
19351945
zDflt[0] = dflt + '0';
19361946
zDflt[1] = 0;
19371947
cookie_link_parameter("diff","diff", zDflt);
1938
- return atoi(PD_NoBot("diff",zDflt));
1948
+ res = atoi(PD_NoBot("diff",zDflt));
1949
+ if( isBot && res>0 && robot_restrict("diff") ){
1950
+ cgi_reply();
1951
+ fossil_exit(0);
1952
+ }
1953
+ return res;
19391954
}
19401955
19411956
19421957
/*
19431958
** WEBPAGE: fdiff
19441959
--- src/info.c
+++ src/info.c
@@ -1228,17 +1228,19 @@
1228 append_file_change_line(zUuid, zName, zOld, zNew, zOldName,
1229 pCfg,mperm);
1230 }
1231 db_finalize(&q3);
1232 @ </div>
1233 @ <script nonce='%h(style_nonce())'>;/* info.c:%d(__LINE__) */
1234 @ document.getElementById('changes_section').textContent = 'Changes ' +
1235 @ '(%d(g.diffCnt[0]) file' + (%d(g.diffCnt[0])===1 ? '' : 's') + ': ' +
1236 @ '+%d(g.diffCnt[1]) ' +
1237 @ '−%d(g.diffCnt[2]))'
1238 @ </script>
1239 append_diff_javascript(diffType);
 
 
1240 style_finish_page();
1241 }
1242
1243 /*
1244 ** WEBPAGE: winfo
@@ -1926,18 +1928,31 @@
1926 ** * The "preferred-diff-type" setting
1927 ** * 1 for mobile and 2 for desktop, based on the UserAgent
1928 */
1929 int preferred_diff_type(void){
1930 int dflt;
 
 
1931 static char zDflt[2]
1932 /*static b/c cookie_link_parameter() does not copy it!*/;
1933 dflt = db_get_int("preferred-diff-type",-99);
1934 if( dflt<=0 ) dflt = user_agent_is_likely_mobile() ? 1 : 2;
 
 
 
 
 
 
1935 zDflt[0] = dflt + '0';
1936 zDflt[1] = 0;
1937 cookie_link_parameter("diff","diff", zDflt);
1938 return atoi(PD_NoBot("diff",zDflt));
 
 
 
 
 
1939 }
1940
1941
1942 /*
1943 ** WEBPAGE: fdiff
1944
--- src/info.c
+++ src/info.c
@@ -1228,17 +1228,19 @@
1228 append_file_change_line(zUuid, zName, zOld, zNew, zOldName,
1229 pCfg,mperm);
1230 }
1231 db_finalize(&q3);
1232 @ </div>
1233 if( diffType!=0 ){
1234 @ <script nonce='%h(style_nonce())'>;/* info.c:%d(__LINE__) */
1235 @ document.getElementById('changes_section').textContent = 'Changes ' +
1236 @ '(%d(g.diffCnt[0]) file' + (%d(g.diffCnt[0])===1 ? '' : 's') + ': ' +
1237 @ '+%d(g.diffCnt[1]) ' +
1238 @ '−%d(g.diffCnt[2]))'
1239 @ </script>
1240 append_diff_javascript(diffType);
1241 }
1242 style_finish_page();
1243 }
1244
1245 /*
1246 ** WEBPAGE: winfo
@@ -1926,18 +1928,31 @@
1928 ** * The "preferred-diff-type" setting
1929 ** * 1 for mobile and 2 for desktop, based on the UserAgent
1930 */
1931 int preferred_diff_type(void){
1932 int dflt;
1933 int res;
1934 int isBot;
1935 static char zDflt[2]
1936 /*static b/c cookie_link_parameter() does not copy it!*/;
1937 if( client_might_be_a_robot() ){
1938 dflt = 0;
1939 isBot = 1;
1940 }else{
1941 dflt = db_get_int("preferred-diff-type",-99);
1942 if( dflt<=0 ) dflt = user_agent_is_likely_mobile() ? 1 : 2;
1943 isBot = 0;
1944 }
1945 zDflt[0] = dflt + '0';
1946 zDflt[1] = 0;
1947 cookie_link_parameter("diff","diff", zDflt);
1948 res = atoi(PD_NoBot("diff",zDflt));
1949 if( isBot && res>0 && robot_restrict("diff") ){
1950 cgi_reply();
1951 fossil_exit(0);
1952 }
1953 return res;
1954 }
1955
1956
1957 /*
1958 ** WEBPAGE: fdiff
1959

Keyboard Shortcuts

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