Fossil SCM
Do not show diffs on the /vinfo page unless we know that the client is not a robot.
Commit
3710202914e5ddd15f3844be5f116503cb6a5d26f83ef7c73cda80072e33fa08
Parent
4fa618faf1e70f8…
1 file changed
+25
-10
+25
-10
| --- src/info.c | ||
| +++ src/info.c | ||
| @@ -1228,17 +1228,19 @@ | ||
| 1228 | 1228 | append_file_change_line(zUuid, zName, zOld, zNew, zOldName, |
| 1229 | 1229 | pCfg,mperm); |
| 1230 | 1230 | } |
| 1231 | 1231 | db_finalize(&q3); |
| 1232 | 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); | |
| 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 | + } | |
| 1240 | 1242 | style_finish_page(); |
| 1241 | 1243 | } |
| 1242 | 1244 | |
| 1243 | 1245 | /* |
| 1244 | 1246 | ** WEBPAGE: winfo |
| @@ -1926,18 +1928,31 @@ | ||
| 1926 | 1928 | ** * The "preferred-diff-type" setting |
| 1927 | 1929 | ** * 1 for mobile and 2 for desktop, based on the UserAgent |
| 1928 | 1930 | */ |
| 1929 | 1931 | int preferred_diff_type(void){ |
| 1930 | 1932 | int dflt; |
| 1933 | + int res; | |
| 1934 | + int isBot; | |
| 1931 | 1935 | static char zDflt[2] |
| 1932 | 1936 | /*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 | + } | |
| 1935 | 1945 | zDflt[0] = dflt + '0'; |
| 1936 | 1946 | zDflt[1] = 0; |
| 1937 | 1947 | 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; | |
| 1939 | 1954 | } |
| 1940 | 1955 | |
| 1941 | 1956 | |
| 1942 | 1957 | /* |
| 1943 | 1958 | ** WEBPAGE: fdiff |
| 1944 | 1959 |
| --- 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 |