Fossil

Check-in [60736abcf6]
Login

Check-in [60736abcf6]

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Performance optimization for /hexdump. Also, prevent /hexdump from working for robots, as robots like to download thousands of /hexdumps from servers and soak up CPU time and bandwidth, and I cannot think of any reason for a robot to actually need a hexdump.
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 60736abcf6b28b85746ad64a99ccbee3b6694ba744353326f02ff4534ab0fc57
User & Date: drh 2021-01-10 01:40:41.027
Context
2021-01-10
11:40
Updated the 'common commands' list in fossil.1 (man page) to match the current help output. ... (check-in: 603e9b3865 user: stephan tags: trunk)
01:40
Performance optimization for /hexdump. Also, prevent /hexdump from working for robots, as robots like to download thousands of /hexdumps from servers and soak up CPU time and bandwidth, and I cannot think of any reason for a robot to actually need a hexdump. ... (check-in: 60736abcf6 user: drh tags: trunk)
2021-01-09
18:43
Always include the "Annotate" and "Blame" submenu items of the /file page, not just for cases of text/ mimetypes, since some files (ex: Makefile.in) do not have a well-defined mimetype, but we do want to Annotate them. ... (check-in: b84b8bf359 user: drh tags: trunk)
Changes
Unified Diff Ignore Whitespace Patch
Changes to src/info.c.
1899
1900
1901
1902
1903
1904
1905

1906
1907
1908
1909
1910
1911


















1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
      }else{
        zLine[k+1] = ' ';
        zLine[k+2] = ' ';
      }
    }
    zLine[53] = ' ';
    zLine[54] = ' ';

    for(j=0; j<16; j++){
      k = j+55;
      if( i+j<n ){
        unsigned char c = x[i+j];
        if( c>=0x20 && c<=0x7e ){
          zLine[k] = c;


















        }else{
          zLine[k] = '.';
        }
      }else{
        zLine[k] = 0;
      }
    }
    zLine[71] = 0;
    @ %h(zLine)
  }
}

/*
** WEBPAGE: hexdump
** URL: /hexdump?name=ARTIFACTID
**







>
|
<


|
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>

|


|


|
|







1899
1900
1901
1902
1903
1904
1905
1906
1907

1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
      }else{
        zLine[k+1] = ' ';
        zLine[k+2] = ' ';
      }
    }
    zLine[53] = ' ';
    zLine[54] = ' ';
    cgi_append_content(zLine, 55);
    for(j=k=0; j<16; j++){

      if( i+j<n ){
        unsigned char c = x[i+j];
        if( c>'>' && c<=0x7e ){
          zLine[k++] = c;
        }else if( c=='>' ){
          zLine[k++] = '&';
          zLine[k++] = 'g';
          zLine[k++] = 't';
          zLine[k++] = ';';
        }else if( c=='<' ){
          zLine[k++] = '&';
          zLine[k++] = 'l';
          zLine[k++] = 't';
          zLine[k++] = ';';
        }else if( c=='&' ){
          zLine[k++] = '&';
          zLine[k++] = 'a';
          zLine[k++] = 'm';
          zLine[k++] = 'p';
          zLine[k++] = ';';
        }else if( c>=' ' ){
          zLine[k++] = c;
        }else{
          zLine[k++] = '.';
        }
      }else{
        break;
      }
    }
    zLine[k++] = '\n';
    cgi_append_content(zLine, k);
  }
}

/*
** WEBPAGE: hexdump
** URL: /hexdump?name=ARTIFACTID
**
1964
1965
1966
1967
1968
1969
1970







1971
1972
1973

1974
1975
1976
1977
1978
1979
1980
  blob_zero(&downloadName);
  if( P("verbose")!=0 ) objdescFlags |= OBJDESC_DETAIL;
  object_description(rid, objdescFlags, 0, &downloadName);
  style_submenu_element("Download", "%R/raw/%s?at=%T",
                        zUuid, file_tail(blob_str(&downloadName)));
  @ <hr />
  content_get(rid, &content);







  @ <blockquote><pre>
  hexdump(&content);
  @ </pre></blockquote>

  style_finish_page();
}

/*
** Look for "ci" and "filename" query parameters.  If found, try to
** use them to extract the record ID of an artifact for the file.
**







>
>
>
>
>
>
>
|
|
|
>







1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
  blob_zero(&downloadName);
  if( P("verbose")!=0 ) objdescFlags |= OBJDESC_DETAIL;
  object_description(rid, objdescFlags, 0, &downloadName);
  style_submenu_element("Download", "%R/raw/%s?at=%T",
                        zUuid, file_tail(blob_str(&downloadName)));
  @ <hr />
  content_get(rid, &content);
  if( !g.isHuman ){
    /* Prevent robots from running hexdump on megabyte-sized source files
    ** and there by eating up lots of CPU time and bandwidth.  There is
    ** no good reason for a robot to need a hexdump. */
    @ <p>A hex dump of this file is not available.
    @  Please download the raw binary file and generate a hex dump yourself.</p>
  }else{
    @ <blockquote><pre>
    hexdump(&content);
    @ </pre></blockquote>
  }
  style_finish_page();
}

/*
** Look for "ci" and "filename" query parameters.  If found, try to
** use them to extract the record ID of an artifact for the file.
**