Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Changes In Branch verify-options-cgi Excluding Merge-Ins
This is equivalent to a diff from 2b72f337be to d276fd9b77
2023-07-18
| ||
13:36 | Improved defense against denial-of-service caused by hackers pounding Fossil with repeated requests that contain SQL injection attempts. If SQL injection is attempted, return a "Begone, Knave!" page with status code 418. ... (check-in: 57f1e87254 user: drh tags: trunk) | |
2023-07-17
| ||
12:31 | Fix should have gone on the verify-options-cgi branch, not on trunk. ... (Closed-Leaf check-in: d276fd9b77 user: drh tags: verify-options-cgi) | |
12:28 | Make sure query parameter "t" is marked as isFetched even if it is renamed from "r". ... (check-in: 2b72f337be user: drh tags: trunk) | |
12:18 | In /raw and /secureraw, ensure that the "m" and "at" vars are fetched before the malice check. Typo fix in cgi.c. ... (check-in: 83015b0d9a user: stephan tags: verify-options-cgi) | |
2023-07-13
| ||
12:13 | Reconcile a test in the FTS search with its original intent in [196dfedf7fc]; reported in [forum:fa13ae06d|forum post fa13ae06d]. ... (check-in: e88211628b user: danield tags: trunk) | |
Changes to src/branch.c.
︙ | ︙ | |||
856 857 858 859 860 861 862 863 864 865 866 867 868 869 | if( showClosed==0 && showAll==0 && showOpen==0 && colorTest==0 ){ new_brlist_page(); return; } login_check_credentials(); if( !g.perm.Read ){ login_needed(g.anon.Read); return; } if( colorTest ){ showClosed = 0; showAll = 1; } if( showAll ) brFlags = BRL_BOTH; if( showClosed ) brFlags = BRL_CLOSED_ONLY; | > | 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 | if( showClosed==0 && showAll==0 && showOpen==0 && colorTest==0 ){ new_brlist_page(); return; } login_check_credentials(); if( !g.perm.Read ){ login_needed(g.anon.Read); return; } cgi_check_for_malice(); if( colorTest ){ showClosed = 0; showAll = 1; } if( showAll ) brFlags = BRL_BOTH; if( showClosed ) brFlags = BRL_CLOSED_ONLY; |
︙ | ︙ | |||
984 985 986 987 988 989 990 991 992 993 994 995 996 997 | if( !g.perm.Read ){ login_needed(g.anon.Read); return; } style_set_current_feature("branch"); style_header("Branches"); style_submenu_element("List", "brlist"); login_anonymous_available(); timeline_ss_submenu(); @ <h2>The initial check-in for each branch:</h2> blob_append(&sql, timeline_query_for_www(), -1); blob_append_sql(&sql, "AND blob.rid IN (SELECT rid FROM tagxref" " WHERE tagtype>0 AND tagid=%d AND srcid!=0)", TAG_BRANCH); if( fNoHidden || fOnlyHidden ){ const char* zUnaryOp = fNoHidden ? "NOT" : ""; | > | 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 | if( !g.perm.Read ){ login_needed(g.anon.Read); return; } style_set_current_feature("branch"); style_header("Branches"); style_submenu_element("List", "brlist"); login_anonymous_available(); timeline_ss_submenu(); cgi_check_for_malice(); @ <h2>The initial check-in for each branch:</h2> blob_append(&sql, timeline_query_for_www(), -1); blob_append_sql(&sql, "AND blob.rid IN (SELECT rid FROM tagxref" " WHERE tagtype>0 AND tagid=%d AND srcid!=0)", TAG_BRANCH); if( fNoHidden || fOnlyHidden ){ const char* zUnaryOp = fNoHidden ? "NOT" : ""; |
︙ | ︙ |
Changes to src/browse.c.
︙ | ︙ | |||
207 208 209 210 211 212 213 214 215 216 217 218 219 220 | } style_header("%s", zHeader); fossil_free(zHeader); style_adunit_config(ADUNIT_RIGHT_OK); sqlite3_create_function(g.db, "pathelement", 2, SQLITE_UTF8, 0, pathelementFunc, 0, 0); url_initialize(&sURI, "dir"); cgi_query_parameters_to_url(&sURI); /* Compute the title of the page */ if( zD ){ Blob dirname; blob_init(&dirname, 0, 0); hyperlinked_path(zD, &dirname, zCI, "dir", "", 0); | > | 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 | } style_header("%s", zHeader); fossil_free(zHeader); style_adunit_config(ADUNIT_RIGHT_OK); sqlite3_create_function(g.db, "pathelement", 2, SQLITE_UTF8, 0, pathelementFunc, 0, 0); url_initialize(&sURI, "dir"); cgi_check_for_malice(); cgi_query_parameters_to_url(&sURI); /* Compute the title of the page */ if( zD ){ Blob dirname; blob_init(&dirname, 0, 0); hyperlinked_path(zD, &dirname, zCI, "dir", "", 0); |
︙ | ︙ | |||
703 704 705 706 707 708 709 710 711 712 713 714 715 716 | /* If a regular expression is specified, compile it */ zRE = P("re"); if( zRE ){ re_compile(&pRE, zRE, 0); zREx = mprintf("&re=%T", zRE); } /* If the name= parameter is an empty string, make it a NULL pointer */ if( zD && strlen(zD)==0 ){ zD = 0; } /* If a specific check-in is requested, fetch and parse it. If the ** specific check-in does not exist, clear zCI. zCI==0 will cause all ** files from all check-ins to be displayed. | > | 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 | /* If a regular expression is specified, compile it */ zRE = P("re"); if( zRE ){ re_compile(&pRE, zRE, 0); zREx = mprintf("&re=%T", zRE); } cgi_check_for_malice(); /* If the name= parameter is an empty string, make it a NULL pointer */ if( zD && strlen(zD)==0 ){ zD = 0; } /* If a specific check-in is requested, fetch and parse it. If the ** specific check-in does not exist, clear zCI. zCI==0 will cause all ** files from all check-ins to be displayed. |
︙ | ︙ | |||
1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 | isBranchCI = branch_includes_uuid(zName,zUuid); baseTime = db_double(0.0,"SELECT mtime FROM event WHERE objid=%d", rid); zNow = db_text("", "SELECT datetime(mtime,toLocal()) FROM event" " WHERE objid=%d", rid); style_submenu_element("Tree-View", "%R/tree?ci=%T&mtime=1&type=tree", zName); style_header("File Ages"); zGlob = P("glob"); compute_fileage(rid,zGlob); db_multi_exec("CREATE INDEX fileage_ix1 ON fileage(mid,pathname);"); if( fossil_strcmp(zName,"tip")==0 ){ @ <h1>Files in the %z(href("%R/info?name=tip"))latest check-in</a> }else if( isBranchCI ){ @ <h1>Files in the %z(href("%R/info?name=%T",zName))latest check-in</a> | > | 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 | isBranchCI = branch_includes_uuid(zName,zUuid); baseTime = db_double(0.0,"SELECT mtime FROM event WHERE objid=%d", rid); zNow = db_text("", "SELECT datetime(mtime,toLocal()) FROM event" " WHERE objid=%d", rid); style_submenu_element("Tree-View", "%R/tree?ci=%T&mtime=1&type=tree", zName); style_header("File Ages"); zGlob = P("glob"); cgi_check_for_malice(); compute_fileage(rid,zGlob); db_multi_exec("CREATE INDEX fileage_ix1 ON fileage(mid,pathname);"); if( fossil_strcmp(zName,"tip")==0 ){ @ <h1>Files in the %z(href("%R/info?name=tip"))latest check-in</a> }else if( isBranchCI ){ @ <h1>Files in the %z(href("%R/info?name=%T",zName))latest check-in</a> |
︙ | ︙ |
Changes to src/cgi.c.
︙ | ︙ | |||
747 748 749 750 751 752 753 754 755 756 757 758 759 760 | static int seqQP = 0; /* Sequence numbers */ static struct QParam { /* One entry for each query parameter or cookie */ const char *zName; /* Parameter or cookie name */ const char *zValue; /* Value of the query parameter or cookie */ int seq; /* Order of insertion */ char isQP; /* True for query parameters */ char cTag; /* Tag on query parameters */ } *aParamQP; /* An array of all parameters and cookies */ /* ** Add another query parameter or cookie to the parameter set. ** zName is the name of the query parameter or cookie and zValue ** is its fully decoded value. ** | > | 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 | static int seqQP = 0; /* Sequence numbers */ static struct QParam { /* One entry for each query parameter or cookie */ const char *zName; /* Parameter or cookie name */ const char *zValue; /* Value of the query parameter or cookie */ int seq; /* Order of insertion */ char isQP; /* True for query parameters */ char cTag; /* Tag on query parameters */ char isFetched; /* 1 if the var is requested via P/PD() */ } *aParamQP; /* An array of all parameters and cookies */ /* ** Add another query parameter or cookie to the parameter set. ** zName is the name of the query parameter or cookie and zValue ** is its fully decoded value. ** |
︙ | ︙ | |||
774 775 776 777 778 779 780 781 782 783 784 785 786 787 | aParamQP[nUsedQP].zValue = zValue; if( g.fHttpTrace ){ fprintf(stderr, "# cgi: %s = [%s]\n", zName, zValue); } aParamQP[nUsedQP].seq = seqQP++; aParamQP[nUsedQP].isQP = isQP; aParamQP[nUsedQP].cTag = 0; nUsedQP++; sortQP = 1; } /* ** Add another query parameter or cookie to the parameter set. ** zName is the name of the query parameter or cookie and zValue | > | 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 | aParamQP[nUsedQP].zValue = zValue; if( g.fHttpTrace ){ fprintf(stderr, "# cgi: %s = [%s]\n", zName, zValue); } aParamQP[nUsedQP].seq = seqQP++; aParamQP[nUsedQP].isQP = isQP; aParamQP[nUsedQP].cTag = 0; aParamQP[nUsedQP].isFetched = 0; nUsedQP++; sortQP = 1; } /* ** Add another query parameter or cookie to the parameter set. ** zName is the name of the query parameter or cookie and zValue |
︙ | ︙ | |||
1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 | lo = 0; hi = nUsedQP-1; while( lo<=hi ){ mid = (lo+hi)/2; c = fossil_strcmp(aParamQP[mid].zName, zName); if( c==0 ){ CGIDEBUG(("mem-match [%s] = [%s]\n", zName, aParamQP[mid].zValue)); return aParamQP[mid].zValue; }else if( c>0 ){ hi = mid-1; }else{ lo = mid+1; } } | > | 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 | lo = 0; hi = nUsedQP-1; while( lo<=hi ){ mid = (lo+hi)/2; c = fossil_strcmp(aParamQP[mid].zName, zName); if( c==0 ){ CGIDEBUG(("mem-match [%s] = [%s]\n", zName, aParamQP[mid].zValue)); aParamQP[mid].isFetched = 1; return aParamQP[mid].zValue; }else if( c>0 ){ hi = mid-1; }else{ lo = mid+1; } } |
︙ | ︙ | |||
1528 1529 1530 1531 1532 1533 1534 | CGIDEBUG(("no-match [%s]\n", zName)); return zDefault; } /* ** Renders the "begone, spider" page and exits. */ | | < > | | > > | | | > | | | | 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 | CGIDEBUG(("no-match [%s]\n", zName)); return zDefault; } /* ** Renders the "begone, spider" page and exits. */ static void cgi_begone_spider(const char *zName){ Blob content = empty_blob; cgi_set_content(&content); style_set_current_feature("test"); style_submenu_enable(0); style_header("Malicious Query Detected"); @ <h2>Begone, Knave!</h2> @ <p>This page was generated because Fossil detected an (unsuccessful) @ SQL injection attack or other nefarious content in your HTTP request. @ @ <p>If you believe you are innocent and have reached this page in error, @ contact the Fossil developers on the Fossil-SCM Forum. Type @ "fossil-scm forum" into any search engine to locate the Fossil-SCM Forum. style_finish_page(); cgi_set_status(418,"I'm a teapot"); cgi_reply(); fossil_errorlog("possible hack attempt - 418 response on \"%s\"", zName); exit(0); } /* ** If looks_like_sql_injection() returns true for the given string, calls ** cgi_begone_spider() and does not return, else this function has no ** side effects. The range of checks performed by this function may ** be extended in the future. ** ** Checks are omitted for any logged-in user. ** ** This is NOT a defense against SQL injection. Fossil should easily be ** proof against SQL injection without this routine. Rather, this is an ** attempt to avoid denial-of-service caused by persistent spiders that hammer ** the server with dozens or hundreds of SQL injection attempts per second ** against pages (such as /vdiff) that are expensive to compute. In other ** words, this is an effort to reduce the CPU load imposed by malicious ** spiders. It is not an effect defense against SQL injection vulnerabilities. */ void cgi_value_spider_check(const char *zTxt, const char *zName){ if( g.zLogin==0 && looks_like_sql_injection(zTxt) ){ cgi_begone_spider(zName); } } /* ** A variant of cgi_parameter() with the same semantics except that if ** cgi_parameter(zName,zDefault) returns a value other than zDefault ** then it passes that value to cgi_value_spider_check(). */ const char *cgi_parameter_nosql(const char *zName, const char *zDefault){ const char *zTxt = cgi_parameter(zName, zDefault); if( zTxt!=zDefault ){ cgi_value_spider_check(zTxt, zName); } return zTxt; } /* ** Return the value of the first defined query parameter or cookie whose ** name appears in the list of arguments. Or if no parameter is found, |
︙ | ︙ | |||
1768 1769 1770 1771 1772 1773 1774 | if( fossil_strnicmp("fossil-",zName,7)==0 ) continue; } switch( eDest ){ case 0: { cgi_printf("%h = %h <br>\n", zName, aParamQP[i].zValue); break; } | | | 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 | if( fossil_strnicmp("fossil-",zName,7)==0 ) continue; } switch( eDest ){ case 0: { cgi_printf("%h = %h <br>\n", zName, aParamQP[i].zValue); break; } case 1: { fossil_trace("%s = %s\n", zName, aParamQP[i].zValue); break; } case 2: { cgi_debug("%s = %s\n", zName, aParamQP[i].zValue); break; } |
︙ | ︙ | |||
2702 2703 2704 2705 2706 2707 2708 | */ int cgi_from_mobile(void){ const char *zAgent = P("HTTP_USER_AGENT"); if( zAgent==0 ) return 0; if( sqlite3_strglob("*iPad*", zAgent)==0 ) return 0; return sqlite3_strlike("%mobile%", zAgent, 0)==0; } | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 2708 2709 2710 2711 2712 2713 2714 2715 2716 2717 2718 2719 2720 2721 2722 2723 2724 2725 2726 2727 2728 2729 2730 2731 2732 2733 2734 2735 2736 2737 2738 2739 2740 2741 2742 2743 2744 2745 2746 2747 2748 2749 2750 2751 2752 | */ int cgi_from_mobile(void){ const char *zAgent = P("HTTP_USER_AGENT"); if( zAgent==0 ) return 0; if( sqlite3_strglob("*iPad*", zAgent)==0 ) return 0; return sqlite3_strlike("%mobile%", zAgent, 0)==0; } /* ** Look for query or POST parameters that: ** ** (1) Have not been used ** (2) Appear to be malicious attempts to break into or otherwise ** harm the system, for example via SQL injection ** ** If any such parameters are seen, a 418 ("I'm a teapot") return is ** generated and processing aborts - this routine does not return. ** ** When Fossil is launched via CGI from althttpd, the 418 return signals ** the webserver to put the requestor IP address into "timeout", blocking ** subsequent requests for 5 minutes. ** ** Fossil is not subject to any SQL injections, as far as anybody knows. ** This routine is not necessary for the security of the system (though ** an extra layer of security never hurts). The main purpose here is ** to shutdown malicious attack spiders and prevent them from burning ** lots of CPU cycles and bogging down the website. In other words, the ** objective of this routine is to help prevent denial-of-service. ** ** Usage Hint: Put a call to this routine as late in the webpage ** implementation as possible, ideally just before it begins doing ** potentially CPU-intensive computations and after all query parameters ** have been consulted. */ void cgi_check_for_malice(void){ struct QParam * pParam; int i; for(i = 0; i < nUsedQP; ++i){ pParam = &aParamQP[i]; if(0 == pParam->isFetched && fossil_islower(pParam->zName[0])){ cgi_value_spider_check(pParam->zValue, pParam->zName); } } } |
Changes to src/clone.c.
︙ | ︙ | |||
396 397 398 399 400 401 402 403 404 405 406 407 408 409 | ** WEBPAGE: download ** ** Provide a simple page that enables newbies to download the latest tarball or ** ZIP archive, and provides instructions on how to clone. */ void download_page(void){ login_check_credentials(); style_header("Download Page"); if( !g.perm.Zip ){ @ <p>Bummer. You do not have permission to download. if( g.zLogin==0 || g.zLogin[0]==0 ){ @ Maybe it would work better if you @ %z(href("%R/login"))logged in</a>. }else{ | > | 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 | ** WEBPAGE: download ** ** Provide a simple page that enables newbies to download the latest tarball or ** ZIP archive, and provides instructions on how to clone. */ void download_page(void){ login_check_credentials(); cgi_check_for_malice(); style_header("Download Page"); if( !g.perm.Zip ){ @ <p>Bummer. You do not have permission to download. if( g.zLogin==0 || g.zLogin[0]==0 ){ @ Maybe it would work better if you @ %z(href("%R/login"))logged in</a>. }else{ |
︙ | ︙ |
Changes to src/descendants.c.
︙ | ︙ | |||
574 575 576 577 578 579 580 581 582 583 584 585 586 587 | if( !showClosed ){ style_submenu_element("Closed", "%s", url_render(&url, "closed", "", 0, 0)); } if( showClosed || showAll ){ style_submenu_element("Open", "%s", url_render(&url, 0, 0, 0, 0)); } url_reset(&url); style_set_current_feature("leaves"); style_header("Leaves"); login_anonymous_available(); timeline_ss_submenu(); #if 0 style_sidebox_begin("Nomenclature:", "33%"); @ <ol> | > | 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 | if( !showClosed ){ style_submenu_element("Closed", "%s", url_render(&url, "closed", "", 0, 0)); } if( showClosed || showAll ){ style_submenu_element("Open", "%s", url_render(&url, 0, 0, 0, 0)); } url_reset(&url); cgi_check_for_malice(); style_set_current_feature("leaves"); style_header("Leaves"); login_anonymous_available(); timeline_ss_submenu(); #if 0 style_sidebox_begin("Nomenclature:", "33%"); @ <ol> |
︙ | ︙ |
Changes to src/diff.c.
︙ | ︙ | |||
3579 3580 3581 3582 3583 3584 3585 3586 3587 3588 3589 3590 3591 3592 | zRevision = PD("checkin",0); zOrigin = P("origin"); zLimit = P("limit"); showLog = PB("log"); fileVers = PB("filevers"); ignoreWs = PB("w"); if( ignoreWs ) annFlags |= DIFF_IGNORE_ALLWS; /* compute the annotation */ annotate_file(&ann, zFilename, zRevision, zLimit, zOrigin, annFlags); zCI = ann.aVers[0].zMUuid; /* generate the web page */ style_set_current_feature("annotate"); | > | 3579 3580 3581 3582 3583 3584 3585 3586 3587 3588 3589 3590 3591 3592 3593 | zRevision = PD("checkin",0); zOrigin = P("origin"); zLimit = P("limit"); showLog = PB("log"); fileVers = PB("filevers"); ignoreWs = PB("w"); if( ignoreWs ) annFlags |= DIFF_IGNORE_ALLWS; cgi_check_for_malice(); /* compute the annotation */ annotate_file(&ann, zFilename, zRevision, zLimit, zOrigin, annFlags); zCI = ann.aVers[0].zMUuid; /* generate the web page */ style_set_current_feature("annotate"); |
︙ | ︙ |
Changes to src/diffcmd.c.
︙ | ︙ | |||
1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 | ** ** Show a patch that goes from check-in FROM to check-in TO. */ void vpatch_page(void){ const char *zFrom = P("from"); const char *zTo = P("to"); DiffConfig DCfg; login_check_credentials(); if( !g.perm.Read ){ login_needed(g.anon.Read); return; } if( zFrom==0 || zTo==0 ) fossil_redirect_home(); fossil_nice_default(); cgi_set_content_type("text/plain"); diff_config_init(&DCfg, DIFF_VERBOSE); | > | 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 | ** ** Show a patch that goes from check-in FROM to check-in TO. */ void vpatch_page(void){ const char *zFrom = P("from"); const char *zTo = P("to"); DiffConfig DCfg; cgi_check_for_malice(); login_check_credentials(); if( !g.perm.Read ){ login_needed(g.anon.Read); return; } if( zFrom==0 || zTo==0 ) fossil_redirect_home(); fossil_nice_default(); cgi_set_content_type("text/plain"); diff_config_init(&DCfg, DIFF_VERBOSE); |
︙ | ︙ |
Changes to src/dispatch.c.
︙ | ︙ | |||
811 812 813 814 815 816 817 818 819 820 821 | ** raw Show the raw help text without any formatting. ** (Used for debugging.) */ void help_page(void){ const char *zCmd = P("cmd"); if( zCmd==0 ) zCmd = P("name"); if( zCmd && *zCmd ){ int rc; const CmdOrPage *pCmd = 0; | > | | 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 | ** raw Show the raw help text without any formatting. ** (Used for debugging.) */ void help_page(void){ const char *zCmd = P("cmd"); if( zCmd==0 ) zCmd = P("name"); cgi_check_for_malice(); if( zCmd && *zCmd ){ int rc; const CmdOrPage *pCmd = 0; style_set_current_feature("tkt"); style_header("Help: %s", zCmd); style_submenu_element("Command-List", "%R/help"); rc = dispatch_name_search(zCmd, CMDFLAG_ANY|CMDFLAG_PREFIX, &pCmd); if( *zCmd=='/' ){ /* Some of the webpages require query parameters in order to work. ** @ <h1>The "<a href='%R%s(zCmd)'>%s(zCmd)</a>" page:</h1> */ |
︙ | ︙ |
Changes to src/doc.c.
︙ | ︙ | |||
1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 | Th_Store("doc_name", zName); if( vid ){ Th_Store("doc_version", db_text(0, "SELECT '[' || substr(uuid,1,10) || ']'" " FROM blob WHERE rid=%d", vid)); Th_Store("doc_date", db_text(0, "SELECT datetime(mtime) FROM event" " WHERE objid=%d AND type='ci'", vid)); } document_render(&filebody, zMime, zDfltTitle, zName); if( nMiss>=count(azSuffix) ) cgi_set_status(404, "Not Found"); db_end_transaction(0); return; /* Jump here when unable to locate the document */ doc_not_found: | > | 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 | Th_Store("doc_name", zName); if( vid ){ Th_Store("doc_version", db_text(0, "SELECT '[' || substr(uuid,1,10) || ']'" " FROM blob WHERE rid=%d", vid)); Th_Store("doc_date", db_text(0, "SELECT datetime(mtime) FROM event" " WHERE objid=%d AND type='ci'", vid)); } cgi_check_for_malice(); document_render(&filebody, zMime, zDfltTitle, zName); if( nMiss>=count(azSuffix) ) cgi_set_status(404, "Not Found"); db_end_transaction(0); return; /* Jump here when unable to locate the document */ doc_not_found: |
︙ | ︙ | |||
1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 | ** ** s=PATTERN Search for PATTERN */ void doc_search_page(void){ const int isSearch = P("s")!=0; login_check_credentials(); style_header("Document Search%s", isSearch ? " Results" : ""); search_screen(SRCH_DOC, 0); style_finish_page(); } | > | 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 | ** ** s=PATTERN Search for PATTERN */ void doc_search_page(void){ const int isSearch = P("s")!=0; login_check_credentials(); style_header("Document Search%s", isSearch ? " Results" : ""); cgi_check_for_malice(); search_screen(SRCH_DOC, 0); style_finish_page(); } |
Changes to src/event.c.
︙ | ︙ | |||
127 128 129 130 131 132 133 134 135 136 137 138 139 140 | if( !zVerbose ){ zVerbose = P("detail"); /* deprecated */ } verboseFlag = (zVerbose!=0) && !is_false(zVerbose); /* Extract the event content. */ pTNote = manifest_get(rid, CFTYPE_EVENT, 0); if( pTNote==0 ){ fossil_fatal("Object #%d is not a tech-note", rid); } zMimetype = wiki_filter_mimetypes(PD("mimetype",pTNote->zMimetype)); blob_init(&fullbody, pTNote->zWiki, -1); blob_init(&title, 0, 0); | > | 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 | if( !zVerbose ){ zVerbose = P("detail"); /* deprecated */ } verboseFlag = (zVerbose!=0) && !is_false(zVerbose); /* Extract the event content. */ cgi_check_for_malice(); pTNote = manifest_get(rid, CFTYPE_EVENT, 0); if( pTNote==0 ){ fossil_fatal("Object #%d is not a tech-note", rid); } zMimetype = wiki_filter_mimetypes(PD("mimetype",pTNote->zMimetype)); blob_init(&fullbody, pTNote->zWiki, -1); blob_init(&title, 0, 0); |
︙ | ︙ |
Changes to src/finfo.c.
︙ | ︙ | |||
421 422 423 424 425 426 427 428 429 430 431 432 433 434 | ridTo = name_to_typed_rid(P("to"),"ci"); path_shortest_stored_in_ancestor_table(ridFrom,ridTo); }else{ compute_direct_ancestors(ridFrom); } } url_add_parameter(&url, "name", zFilename); blob_zero(&sql); if( ridCi ){ /* If we will be tracking changes across renames, some extra temp ** tables (implemented as CTEs) are required */ blob_append_sql(&sql, /* The clade(fid,fnid) table is the set of all (fid,fnid) pairs ** that should participate in the output. Clade is computed by | > | 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 | ridTo = name_to_typed_rid(P("to"),"ci"); path_shortest_stored_in_ancestor_table(ridFrom,ridTo); }else{ compute_direct_ancestors(ridFrom); } } url_add_parameter(&url, "name", zFilename); cgi_check_for_malice(); blob_zero(&sql); if( ridCi ){ /* If we will be tracking changes across renames, some extra temp ** tables (implemented as CTEs) are required */ blob_append_sql(&sql, /* The clade(fid,fnid) table is the set of all (fid,fnid) pairs ** that should participate in the output. Clade is computed by |
︙ | ︙ |
Changes to src/forum.c.
︙ | ︙ | |||
1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 | if( !g.perm.RdForum ){ login_needed(g.anon.RdForum); return; } if( zName==0 ){ webpage_error("Missing \"name=\" query parameter"); } fpid = symbolic_name_to_rid(zName, "f"); if( fpid<=0 ){ if( fpid==0 ){ webpage_notfound_error("Unknown forum id: \"%s\"", zName); }else{ ambiguous_page(); } | > | 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 | if( !g.perm.RdForum ){ login_needed(g.anon.RdForum); return; } if( zName==0 ){ webpage_error("Missing \"name=\" query parameter"); } cgi_check_for_malice(); fpid = symbolic_name_to_rid(zName, "f"); if( fpid<=0 ){ if( fpid==0 ){ webpage_notfound_error("Unknown forum id: \"%s\"", zName); }else{ ambiguous_page(); } |
︙ | ︙ | |||
1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 | login_check_credentials(); srchFlags = search_restrict(SRCH_FORUM); if( !g.perm.RdForum ){ login_needed(g.anon.RdForum); return; } style_set_current_feature("forum"); style_header( "%s", isSearch ? "Forum Search Results" : "Forum" ); style_submenu_element("Timeline", "%R/timeline?ss=v&y=f&vfx"); if( g.perm.WrForum ){ style_submenu_element("New Thread","%R/forumnew"); }else{ /* Can't combine this with previous case using the ternary operator | > | 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 | login_check_credentials(); srchFlags = search_restrict(SRCH_FORUM); if( !g.perm.RdForum ){ login_needed(g.anon.RdForum); return; } cgi_check_for_malice(); style_set_current_feature("forum"); style_header( "%s", isSearch ? "Forum Search Results" : "Forum" ); style_submenu_element("Timeline", "%R/timeline?ss=v&y=f&vfx"); if( g.perm.WrForum ){ style_submenu_element("New Thread","%R/forumnew"); }else{ /* Can't combine this with previous case using the ternary operator |
︙ | ︙ |
Changes to src/info.c.
︙ | ︙ | |||
504 505 506 507 508 509 510 511 512 513 514 515 516 517 | rid = name_to_rid_www("name"); if( rid==0 ){ style_header("Check-in Information Error"); @ No such object: %h(PD("name","")) style_finish_page(); return; } zHash = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", rid); style_header("Tags and Properties"); zType = whatis_rid_type_label(rid); if(!zType) zType = "Artifact"; @ <h1>Tags and Properties for %s(zType) \ @ %z(href("%R/ci/%!S",zHash))%S(zHash)</a></h1> db_prepare(&q, | > | 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 | rid = name_to_rid_www("name"); if( rid==0 ){ style_header("Check-in Information Error"); @ No such object: %h(PD("name","")) style_finish_page(); return; } cgi_check_for_malice(); zHash = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", rid); style_header("Tags and Properties"); zType = whatis_rid_type_label(rid); if(!zType) zType = "Artifact"; @ <h1>Tags and Properties for %s(zType) \ @ %z(href("%R/ci/%!S",zHash))%S(zHash)</a></h1> db_prepare(&q, |
︙ | ︙ | |||
658 659 660 661 662 663 664 665 666 667 668 669 670 671 | " WHERE blob.rid=%d" " AND event.objid=%d", rid, rid ); zBrName = branch_of_rid(rid); diffType = preferred_diff_type(); if( db_step(&q1)==SQLITE_ROW ){ const char *zUuid = db_column_text(&q1, 0); int nUuid = db_column_bytes(&q1, 0); char *zEUser, *zEComment; const char *zUser; const char *zOrigUser; const char *zComment; | > | 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 | " WHERE blob.rid=%d" " AND event.objid=%d", rid, rid ); zBrName = branch_of_rid(rid); diffType = preferred_diff_type(); cgi_check_for_malice(); if( db_step(&q1)==SQLITE_ROW ){ const char *zUuid = db_column_text(&q1, 0); int nUuid = db_column_bytes(&q1, 0); char *zEUser, *zEComment; const char *zUser; const char *zOrigUser; const char *zComment; |
︙ | ︙ | |||
999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 | /*NOTREACHED*/ } } if( strcmp(zModAction,"approve")==0 ){ moderation_approve('w', rid); } } style_header("Update of \"%h\"", pWiki->zWikiTitle); zUuid = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", rid); zDate = db_text(0, "SELECT datetime(%.17g,toLocal())", pWiki->rDate); style_submenu_element("Raw", "%R/artifact/%s", zUuid); style_submenu_element("History", "%R/whistory?name=%t", pWiki->zWikiTitle); style_submenu_element("Page", "%R/wiki?name=%t", pWiki->zWikiTitle); login_anonymous_available(); | > | 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 | /*NOTREACHED*/ } } if( strcmp(zModAction,"approve")==0 ){ moderation_approve('w', rid); } } cgi_check_for_malice(); style_header("Update of \"%h\"", pWiki->zWikiTitle); zUuid = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", rid); zDate = db_text(0, "SELECT datetime(%.17g,toLocal())", pWiki->rDate); style_submenu_element("Raw", "%R/artifact/%s", zUuid); style_submenu_element("History", "%R/whistory?name=%t", pWiki->zWikiTitle); style_submenu_element("Page", "%R/wiki?name=%t", pWiki->zWikiTitle); login_anonymous_available(); |
︙ | ︙ | |||
1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 | graphFlags |= TIMELINE_NOCOLOR; blob_appendf(&qp, "&nc"); } pCfg = construct_diff_flags(diffType, &DCfg); if( DCfg.diffFlags & DIFF_IGNORE_ALLWS ){ blob_appendf(&qp, "&w"); } style_set_current_feature("vdiff"); if( zBranch==0 ){ style_submenu_element("Path", "%R/timeline?me=%T&you=%T", zFrom, zTo); } if( diffType!=0 ){ style_submenu_element("Hide Diff", "%R/vdiff?diff=0&%b", &qp); } | > | 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 | graphFlags |= TIMELINE_NOCOLOR; blob_appendf(&qp, "&nc"); } pCfg = construct_diff_flags(diffType, &DCfg); if( DCfg.diffFlags & DIFF_IGNORE_ALLWS ){ blob_appendf(&qp, "&w"); } cgi_check_for_malice(); style_set_current_feature("vdiff"); if( zBranch==0 ){ style_submenu_element("Path", "%R/timeline?me=%T&you=%T", zFrom, zTo); } if( diffType!=0 ){ style_submenu_element("Hide Diff", "%R/vdiff?diff=0&%b", &qp); } |
︙ | ︙ | |||
1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 | "%R/annotate?origin=%s&checkin=%s&filename=%T", zOrig, zCkin, zFN); } db_finalize(&q); } if( v1==0 || v2==0 ) fossil_redirect_home(); zRe = P("regex"); if( zRe ) re_compile(&pRe, zRe, 0); if( verbose ) objdescFlags |= OBJDESC_DETAIL; if( isPatch ){ Blob c1, c2, *pOut; DiffConfig DCfg; pOut = cgi_output_blob(); cgi_set_content_type("text/plain"); | > | 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 | "%R/annotate?origin=%s&checkin=%s&filename=%T", zOrig, zCkin, zFN); } db_finalize(&q); } if( v1==0 || v2==0 ) fossil_redirect_home(); zRe = P("regex"); cgi_check_for_malice(); if( zRe ) re_compile(&pRe, zRe, 0); if( verbose ) objdescFlags |= OBJDESC_DETAIL; if( isPatch ){ Blob c1, c2, *pOut; DiffConfig DCfg; pOut = cgi_output_blob(); cgi_set_content_type("text/plain"); |
︙ | ︙ | |||
1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 | ** Return the uninterpreted content of an artifact. Used primarily ** to view artifacts that are images. */ void rawartifact_page(void){ int rid = 0; char *zUuid; if( P("ci") ){ rid = artifact_from_ci_and_filename(0); } if( rid==0 ){ rid = name_to_rid_www("name"); } login_check_credentials(); if( !g.perm.Read ){ login_needed(g.anon.Read); return; } if( rid==0 ) fossil_redirect_home(); zUuid = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", rid); etag_check(ETAG_HASH, zUuid); if( fossil_strcmp(P("name"), zUuid)==0 && login_is_nobody() ){ g.isConst = 1; } free(zUuid); | > > > | 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 | ** Return the uninterpreted content of an artifact. Used primarily ** to view artifacts that are images. */ void rawartifact_page(void){ int rid = 0; char *zUuid; (void)P("at")/*for cgi_check_for_malice()*/; (void)P("m"); if( P("ci") ){ rid = artifact_from_ci_and_filename(0); } if( rid==0 ){ rid = name_to_rid_www("name"); } login_check_credentials(); if( !g.perm.Read ){ login_needed(g.anon.Read); return; } cgi_check_for_malice(); if( rid==0 ) fossil_redirect_home(); zUuid = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", rid); etag_check(ETAG_HASH, zUuid); if( fossil_strcmp(P("name"), zUuid)==0 && login_is_nobody() ){ g.isConst = 1; } free(zUuid); |
︙ | ︙ | |||
1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 | ** is by the full-length SHA1 or SHA3 hash. Abbreviations are not ** accepted. */ void secure_rawartifact_page(void){ int rid = 0; const char *zName = PD("name", ""); login_check_credentials(); if( !g.perm.Read ){ login_needed(g.anon.Read); return; } rid = db_int(0, "SELECT rid FROM blob WHERE uuid=%Q", zName); if( rid==0 ){ cgi_set_status(404, "Not Found"); @ Unknown artifact: "%h(zName)" return; | > > > | 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 | ** is by the full-length SHA1 or SHA3 hash. Abbreviations are not ** accepted. */ void secure_rawartifact_page(void){ int rid = 0; const char *zName = PD("name", ""); (void)P("at")/*for cgi_check_for_malice()*/; (void)P("m"); cgi_check_for_malice(); login_check_credentials(); if( !g.perm.Read ){ login_needed(g.anon.Read); return; } rid = db_int(0, "SELECT rid FROM blob WHERE uuid=%Q", zName); if( rid==0 ){ cgi_set_status(404, "Not Found"); @ Unknown artifact: "%h(zName)" return; |
︙ | ︙ | |||
1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 | if(0){ ajax_route_error(400, "Just testing client-side error handling."); return; } login_check_credentials(); if( !g.perm.Read ){ ajax_route_error(403, "Access requires Read permissions."); return; } #if 1 /* Re-enable this block once this code is integrated somewhere into the UI. */ | > | 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 | if(0){ ajax_route_error(400, "Just testing client-side error handling."); return; } login_check_credentials(); cgi_check_for_malice(); if( !g.perm.Read ){ ajax_route_error(403, "Access requires Read permissions."); return; } #if 1 /* Re-enable this block once this code is integrated somewhere into the UI. */ |
︙ | ︙ | |||
2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 | char *zUuid; u32 objdescFlags = 0; rid = name_to_rid_www("name"); login_check_credentials(); if( !g.perm.Read ){ login_needed(g.anon.Read); return; } if( rid==0 ) fossil_redirect_home(); if( g.perm.Admin ){ const char *zUuid = db_text("", "SELECT uuid FROM blob WHERE rid=%d", rid); if( db_exists("SELECT 1 FROM shun WHERE uuid=%Q", zUuid) ){ style_submenu_element("Unshun", "%R/shun?accept=%s&sub=1#delshun", zUuid); }else{ style_submenu_element("Shun", "%R/shun?shun=%s#addshun", zUuid); } | > | 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 | char *zUuid; u32 objdescFlags = 0; rid = name_to_rid_www("name"); login_check_credentials(); if( !g.perm.Read ){ login_needed(g.anon.Read); return; } if( rid==0 ) fossil_redirect_home(); cgi_check_for_malice(); if( g.perm.Admin ){ const char *zUuid = db_text("", "SELECT uuid FROM blob WHERE rid=%d", rid); if( db_exists("SELECT 1 FROM shun WHERE uuid=%Q", zUuid) ){ style_submenu_element("Unshun", "%R/shun?accept=%s&sub=1#delshun", zUuid); }else{ style_submenu_element("Shun", "%R/shun?shun=%s#addshun", zUuid); } |
︙ | ︙ | |||
2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 | char *zCIUuid = 0; int isSymbolicCI = 0; /* ci= exists and is a symbolic name, not a hash */ int isBranchCI = 0; /* ci= refers to a branch name */ char *zHeader = 0; login_check_credentials(); if( !g.perm.Read ){ login_needed(g.anon.Read); return; } style_set_current_feature("artifact"); /* Capture and normalize the name= and ci= query parameters */ if( zName==0 ){ zName = P("filename"); if( zName==0 ){ zName = P("fn"); | > | 2432 2433 2434 2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 | char *zCIUuid = 0; int isSymbolicCI = 0; /* ci= exists and is a symbolic name, not a hash */ int isBranchCI = 0; /* ci= refers to a branch name */ char *zHeader = 0; login_check_credentials(); if( !g.perm.Read ){ login_needed(g.anon.Read); return; } cgi_check_for_malice(); style_set_current_feature("artifact"); /* Capture and normalize the name= and ci= query parameters */ if( zName==0 ){ zName = P("filename"); if( zName==0 ){ zName = P("fn"); |
︙ | ︙ | |||
2750 2751 2752 2753 2754 2755 2756 2757 2758 2759 2760 2761 2762 2763 | int modPending; const char *zModAction; char *zTktTitle; login_check_credentials(); if( !g.perm.RdTkt ){ login_needed(g.anon.RdTkt); return; } rid = name_to_rid_www("name"); if( rid==0 ){ fossil_redirect_home(); } zUuid = db_text("", "SELECT uuid FROM blob WHERE rid=%d", rid); if( g.perm.Admin ){ if( db_exists("SELECT 1 FROM shun WHERE uuid=%Q", zUuid) ){ style_submenu_element("Unshun", "%R/shun?accept=%s&sub=1#accshun", zUuid); }else{ style_submenu_element("Shun", "%R/shun?shun=%s#addshun", zUuid); } | > | 2764 2765 2766 2767 2768 2769 2770 2771 2772 2773 2774 2775 2776 2777 2778 | int modPending; const char *zModAction; char *zTktTitle; login_check_credentials(); if( !g.perm.RdTkt ){ login_needed(g.anon.RdTkt); return; } rid = name_to_rid_www("name"); if( rid==0 ){ fossil_redirect_home(); } cgi_check_for_malice(); zUuid = db_text("", "SELECT uuid FROM blob WHERE rid=%d", rid); if( g.perm.Admin ){ if( db_exists("SELECT 1 FROM shun WHERE uuid=%Q", zUuid) ){ style_submenu_element("Unshun", "%R/shun?accept=%s&sub=1#accshun", zUuid); }else{ style_submenu_element("Shun", "%R/shun?shun=%s#addshun", zUuid); } |
︙ | ︙ | |||
2860 2861 2862 2863 2864 2865 2866 2867 2868 2869 2870 2871 2872 2873 | Blob uuid; int rid; int rc; int nLen; zName = P("name"); if( zName==0 ) fossil_redirect_home(); nLen = strlen(zName); blob_set(&uuid, zName); if( name_collisions(zName) ){ cgi_set_parameter("src","info"); ambiguous_page(); return; } | > | 2875 2876 2877 2878 2879 2880 2881 2882 2883 2884 2885 2886 2887 2888 2889 | Blob uuid; int rid; int rc; int nLen; zName = P("name"); if( zName==0 ) fossil_redirect_home(); cgi_check_for_malice(); nLen = strlen(zName); blob_set(&uuid, zName); if( name_collisions(zName) ){ cgi_set_parameter("src","info"); ambiguous_page(); return; } |
︙ | ︙ |
Changes to src/login.c.
︙ | ︙ | |||
573 574 575 576 577 578 579 580 581 582 583 584 585 586 | if( P("pwreset")!=0 && login_self_password_reset_available() ){ /* If the "Reset Password" button in the form was pressed, render ** the Request Password Reset page in place of this one. */ login_reqpwreset_page(); return; } login_check_credentials(); fossil_redirect_to_https_if_needed(1); sqlite3_create_function(g.db, "constant_time_cmp", 2, SQLITE_UTF8, 0, constant_time_cmp_function, 0, 0); zUsername = P("u"); zPasswd = P("p"); anonFlag = g.zLogin==0 && PB("anon"); | > | 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 | if( P("pwreset")!=0 && login_self_password_reset_available() ){ /* If the "Reset Password" button in the form was pressed, render ** the Request Password Reset page in place of this one. */ login_reqpwreset_page(); return; } cgi_check_for_malice(); login_check_credentials(); fossil_redirect_to_https_if_needed(1); sqlite3_create_function(g.db, "constant_time_cmp", 2, SQLITE_UTF8, 0, constant_time_cmp_function, 0, 0); zUsername = P("u"); zPasswd = P("p"); anonFlag = g.zLogin==0 && PB("anon"); |
︙ | ︙ |
Changes to src/lookslike.c.
︙ | ︙ | |||
460 461 462 463 464 465 466 | (lookFlags&LOOK_INVALID)?"yes":"no"); fossil_print("Has flag LOOK_ODD: %s\n",(lookFlags&LOOK_ODD)?"yes":"no"); fossil_print("Has flag LOOK_SHORT: %s\n",(lookFlags&LOOK_SHORT)?"yes":"no"); blob_reset(&blob); } /* | | > | > > > | 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 | (lookFlags&LOOK_INVALID)?"yes":"no"); fossil_print("Has flag LOOK_ODD: %s\n",(lookFlags&LOOK_ODD)?"yes":"no"); fossil_print("Has flag LOOK_SHORT: %s\n",(lookFlags&LOOK_SHORT)?"yes":"no"); blob_reset(&blob); } /* ** Return true if z[i] is the whole word given by zWord in a context that ** might be an attempted SQL injection. */ static int isWholeWord(const char *z, unsigned int i, const char *zWord, int n){ if( i==0 ) return 0; if( sqlite3_strnicmp(z+i, zWord, n)!=0 ) return 0; if( fossil_isalnum(z[i-1]) ) return 0; if( fossil_isalnum(z[i+n]) ) return 0; if( strchr("-)_", z[i-1])!=0 ) return 0; if( strchr("(_", z[i+n])!=0 ) return 0; return 1; } /* ** Returns true if the given text contains certain keywords or ** punctuation which indicate that it might be an SQL injection attempt ** or some other kind of mischief. |
︙ | ︙ | |||
500 501 502 503 504 505 506 | break; case 'n': case 'N': if( isWholeWord(zTxt, i, "null", 4) ) return 1; break; case 'o': case 'O': | | > > | 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 | break; case 'n': case 'N': if( isWholeWord(zTxt, i, "null", 4) ) return 1; break; case 'o': case 'O': if( isWholeWord(zTxt, i, "order", 5) && fossil_isspace(zTxt[i+5]) ){ return 1; } if( isWholeWord(zTxt, i, "or", 2) ) return 1; break; case 's': case 'S': if( isWholeWord(zTxt, i, "select", 6) ) return 1; break; case 'w': |
︙ | ︙ |
Changes to src/name.c.
︙ | ︙ | |||
1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 | int hashClr = PB("hclr"); char *zRange; char *zSha1Bg; char *zSha3Bg; login_check_credentials(); if( !g.perm.Read ){ login_needed(g.anon.Read); return; } style_header("List Of Artifacts"); style_submenu_element("250 Largest", "bigbloblist"); if( g.perm.Admin ){ style_submenu_element("Artifact Log", "rcvfromlist"); } if( !phantomOnly ){ style_submenu_element("Phantoms", "bloblist?phan"); | > | 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 | int hashClr = PB("hclr"); char *zRange; char *zSha1Bg; char *zSha3Bg; login_check_credentials(); if( !g.perm.Read ){ login_needed(g.anon.Read); return; } cgi_check_for_malice(); style_header("List Of Artifacts"); style_submenu_element("250 Largest", "bigbloblist"); if( g.perm.Admin ){ style_submenu_element("Artifact Log", "rcvfromlist"); } if( !phantomOnly ){ style_submenu_element("Phantoms", "bloblist?phan"); |
︙ | ︙ |
Changes to src/search.c.
︙ | ︙ | |||
1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 | ** f -> forum ** all -> everything */ void search_page(void){ const int isSearch = P("s")!=0; login_check_credentials(); style_header("Search%s", isSearch ? " Results" : ""); search_screen(SRCH_ALL, 1); style_finish_page(); } /* ** This is a helper function for search_stext(). Writing into pOut | > | 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 | ** f -> forum ** all -> everything */ void search_page(void){ const int isSearch = P("s")!=0; login_check_credentials(); style_header("Search%s", isSearch ? " Results" : ""); cgi_check_for_malice(); search_screen(SRCH_ALL, 1); style_finish_page(); } /* ** This is a helper function for search_stext(). Writing into pOut |
︙ | ︙ |
Changes to src/stat.c.
︙ | ︙ | |||
805 806 807 808 809 810 811 812 813 814 815 816 817 818 | void repo_tabsize_page(void){ int nPageFree; sqlite3_int64 fsize; char zBuf[100]; login_check_credentials(); if( !g.perm.Read ){ login_needed(g.anon.Read); return; } style_set_current_feature("stat"); style_header("Repository Table Sizes"); style_adunit_config(ADUNIT_RIGHT_OK); style_submenu_element("Stat", "stat"); if( g.perm.Admin ){ style_submenu_element("Schema", "repo_schema"); } | > | 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 | void repo_tabsize_page(void){ int nPageFree; sqlite3_int64 fsize; char zBuf[100]; login_check_credentials(); if( !g.perm.Read ){ login_needed(g.anon.Read); return; } cgi_check_for_malice(); style_set_current_feature("stat"); style_header("Repository Table Sizes"); style_adunit_config(ADUNIT_RIGHT_OK); style_submenu_element("Stat", "stat"); if( g.perm.Admin ){ style_submenu_element("Schema", "repo_schema"); } |
︙ | ︙ | |||
981 982 983 984 985 986 987 988 989 990 991 992 993 994 | ** user without check-in privileges, to prevent excessive usage by ** robots and random passers-by on the internet */ if( !g.perm.Write && !db_get_boolean("artifact_stats_enable",0) ){ login_needed(g.anon.Write); return; } fossil_nice_default(); style_set_current_feature("stat"); style_header("Artifact Statistics"); style_submenu_element("Repository Stats", "stat"); style_submenu_element("Artifact List", "bloblist"); gather_artifact_stats(1); | > | 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 | ** user without check-in privileges, to prevent excessive usage by ** robots and random passers-by on the internet */ if( !g.perm.Write && !db_get_boolean("artifact_stats_enable",0) ){ login_needed(g.anon.Write); return; } cgi_check_for_malice(); fossil_nice_default(); style_set_current_feature("stat"); style_header("Artifact Statistics"); style_submenu_element("Repository Stats", "stat"); style_submenu_element("Artifact List", "bloblist"); gather_artifact_stats(1); |
︙ | ︙ |
Changes to src/statrep.c.
︙ | ︙ | |||
910 911 912 913 914 915 916 917 918 919 920 921 922 923 | } for(i=0; i<count(aViewType); i++){ if( fossil_strcmp(zView, aViewType[i].zVal)==0 ){ eType = aViewType[i].eType; break; } } if( eType!=RPT_NONE ){ int nView = 0; /* Slots used in azView[] */ for(i=0; i<count(aViewType); i++){ azView[nView++] = aViewType[i].zVal; azView[nView++] = aViewType[i].zName; } if( eType!=RPT_BYFILE ){ | > | 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 | } for(i=0; i<count(aViewType); i++){ if( fossil_strcmp(zView, aViewType[i].zVal)==0 ){ eType = aViewType[i].eType; break; } } cgi_check_for_malice(); if( eType!=RPT_NONE ){ int nView = 0; /* Slots used in azView[] */ for(i=0; i<count(aViewType); i++){ azView[nView++] = aViewType[i].zVal; azView[nView++] = aViewType[i].zName; } if( eType!=RPT_BYFILE ){ |
︙ | ︙ |
Changes to src/tag.c.
︙ | ︙ | |||
803 804 805 806 807 808 809 810 811 812 813 814 815 816 | void taglist_page(void){ Stmt q; login_check_credentials(); if( !g.perm.Read ){ login_needed(g.anon.Read); } login_anonymous_available(); style_header("Tags"); style_adunit_config(ADUNIT_RIGHT_OK); style_submenu_element("Timeline", "tagtimeline"); @ <h2>Non-propagating tags:</h2> db_prepare(&q, "SELECT substr(tagname,5)" | > | 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 | void taglist_page(void){ Stmt q; login_check_credentials(); if( !g.perm.Read ){ login_needed(g.anon.Read); } cgi_check_for_malice(); login_anonymous_available(); style_header("Tags"); style_adunit_config(ADUNIT_RIGHT_OK); style_submenu_element("Timeline", "tagtimeline"); @ <h2>Non-propagating tags:</h2> db_prepare(&q, "SELECT substr(tagname,5)" |
︙ | ︙ |
Changes to src/tar.c.
︙ | ︙ | |||
829 830 831 832 833 834 835 836 837 838 839 840 841 842 | @ <p>Tarball named <b>%h(zName).tar.gz</b> holding the content @ of check-in <b>%h(zRid)</b>: @ <input type="submit" value="Download"> @ </form> style_finish_page(); return; } blob_zero(&tarball); if( cache_read(&tarball, zKey)==0 ){ tarball_of_checkin(rid, &tarball, zName, pInclude, pExclude, 0); cache_write(&tarball, zKey); } glob_free(pInclude); glob_free(pExclude); | > | 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 | @ <p>Tarball named <b>%h(zName).tar.gz</b> holding the content @ of check-in <b>%h(zRid)</b>: @ <input type="submit" value="Download"> @ </form> style_finish_page(); return; } cgi_check_for_malice(); blob_zero(&tarball); if( cache_read(&tarball, zKey)==0 ){ tarball_of_checkin(rid, &tarball, zName, pInclude, pExclude, 0); cache_write(&tarball, zKey); } glob_free(pInclude); glob_free(pExclude); |
︙ | ︙ |
Changes to src/timeline.c.
︙ | ︙ | |||
2833 2834 2835 2836 2837 2838 2839 2840 2841 2842 2843 2844 2845 2846 | @ <p class="generalError">%h(zError)</p> } if( zNewerButton ){ @ %z(chref("button","%s",zNewerButton))%h(zNewerButtonLabel)\ @ ↑</a> } www_print_timeline(&q, tmFlags, zThisUser, zThisTag, zBrName, selectedRid, secondaryRid, 0); db_finalize(&q); if( zOlderButton ){ @ %z(chref("button","%s",zOlderButton))%h(zOlderButtonLabel)\ @ ↓</a> } | > | 2833 2834 2835 2836 2837 2838 2839 2840 2841 2842 2843 2844 2845 2846 2847 | @ <p class="generalError">%h(zError)</p> } if( zNewerButton ){ @ %z(chref("button","%s",zNewerButton))%h(zNewerButtonLabel)\ @ ↑</a> } cgi_check_for_malice(); www_print_timeline(&q, tmFlags, zThisUser, zThisTag, zBrName, selectedRid, secondaryRid, 0); db_finalize(&q); if( zOlderButton ){ @ %z(chref("button","%s",zOlderButton))%h(zOlderButtonLabel)\ @ ↓</a> } |
︙ | ︙ |
Changes to src/unversioned.c.
︙ | ︙ | |||
540 541 542 543 544 545 546 547 548 549 550 551 552 553 | int n = 0; const char *zOrderBy = "name"; int showDel = 0; char zSzName[100]; login_check_credentials(); if( !g.perm.Read ){ login_needed(g.anon.Read); return; } etag_check(ETAG_DATA,0); style_header("Unversioned Files"); if( !db_table_exists("repository","unversioned") ){ @ No unversioned files on this server style_finish_page(); return; } | > | 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 | int n = 0; const char *zOrderBy = "name"; int showDel = 0; char zSzName[100]; login_check_credentials(); if( !g.perm.Read ){ login_needed(g.anon.Read); return; } cgi_check_for_malice(); etag_check(ETAG_DATA,0); style_header("Unversioned Files"); if( !db_table_exists("repository","unversioned") ){ @ No unversioned files on this server style_finish_page(); return; } |
︙ | ︙ | |||
652 653 654 655 656 657 658 659 660 661 662 663 664 665 | void uvlist_json_page(void){ Stmt q; char *zSep = "["; Blob json; login_check_credentials(); if( !g.perm.Read ){ login_needed(g.anon.Read); return; } cgi_set_content_type("application/json"); etag_check(ETAG_DATA,0); if( !db_table_exists("repository","unversioned") ){ blob_init(&json, "[]", -1); cgi_set_content(&json); return; } | > | 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 | void uvlist_json_page(void){ Stmt q; char *zSep = "["; Blob json; login_check_credentials(); if( !g.perm.Read ){ login_needed(g.anon.Read); return; } cgi_check_for_malice(); cgi_set_content_type("application/json"); etag_check(ETAG_DATA,0); if( !db_table_exists("repository","unversioned") ){ blob_init(&json, "[]", -1); cgi_set_content(&json); return; } |
︙ | ︙ |
Changes to src/wiki.c.
︙ | ︙ | |||
113 114 115 116 117 118 119 120 121 122 123 124 125 126 | ** The /home, /index, and /not_found pages all redirect to the homepage ** configured by the administrator. */ void home_page(void){ char *zPageName = db_get("project-name",0); char *zIndexPage = db_get("index-page",0); login_check_credentials(); if( zIndexPage ){ const char *zPathInfo = P("PATH_INFO"); while( zIndexPage[0]=='/' ) zIndexPage++; while( zPathInfo[0]=='/' ) zPathInfo++; if( fossil_strcmp(zIndexPage, zPathInfo)==0 ) zIndexPage = 0; } if( zIndexPage ){ | > | 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 | ** The /home, /index, and /not_found pages all redirect to the homepage ** configured by the administrator. */ void home_page(void){ char *zPageName = db_get("project-name",0); char *zIndexPage = db_get("index-page",0); login_check_credentials(); cgi_check_for_malice(); if( zIndexPage ){ const char *zPathInfo = P("PATH_INFO"); while( zIndexPage[0]=='/' ) zIndexPage++; while( zPathInfo[0]=='/' ) zPathInfo++; if( fossil_strcmp(zIndexPage, zPathInfo)==0 ) zIndexPage = 0; } if( zIndexPage ){ |
︙ | ︙ | |||
548 549 550 551 552 553 554 555 556 557 558 559 560 561 | int isPopup = P("popup")!=0; char *zBody = mprintf("%s","<i>Empty Page</i>"); int noSubmenu = P("nsm")!=0 || g.isHome; login_check_credentials(); if( !g.perm.RdWiki ){ login_needed(g.anon.RdWiki); return; } zPageName = P("name"); if( zPageName==0 ){ if( search_restrict(SRCH_WIKI)!=0 ){ wiki_srchpage(); }else{ wiki_helppage(); } return; | > | 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 | int isPopup = P("popup")!=0; char *zBody = mprintf("%s","<i>Empty Page</i>"); int noSubmenu = P("nsm")!=0 || g.isHome; login_check_credentials(); if( !g.perm.RdWiki ){ login_needed(g.anon.RdWiki); return; } zPageName = P("name"); cgi_check_for_malice(); if( zPageName==0 ){ if( search_restrict(SRCH_WIKI)!=0 ){ wiki_srchpage(); }else{ wiki_helppage(); } return; |
︙ | ︙ | |||
1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 | pW1 = manifest_get(rid1, CFTYPE_WIKI, 0); if( pW1==0 ) fossil_redirect_home(); blob_init(&w1, pW1->zWiki, -1); zPid = P("pid"); if( ( zPid==0 || zPid[0] == 0 ) && pW1->nParent ){ zPid = pW1->azParent[0]; } if( zPid && zPid[0] != 0 ){ char *zDate; rid2 = name_to_typed_rid(zPid, "w"); pW2 = manifest_get(rid2, CFTYPE_WIKI, 0); blob_init(&w2, pW2->zWiki, -1); @ <h2>Changes to \ @ "%z(href("%R/whistory?name=%s",pW1->zWikiTitle))%h(pW1->zWikiTitle)</a>" \ | > | 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 | pW1 = manifest_get(rid1, CFTYPE_WIKI, 0); if( pW1==0 ) fossil_redirect_home(); blob_init(&w1, pW1->zWiki, -1); zPid = P("pid"); if( ( zPid==0 || zPid[0] == 0 ) && pW1->nParent ){ zPid = pW1->azParent[0]; } cgi_check_for_malice(); if( zPid && zPid[0] != 0 ){ char *zDate; rid2 = name_to_typed_rid(zPid, "w"); pW2 = manifest_get(rid2, CFTYPE_WIKI, 0); blob_init(&w2, pW2->zWiki, -1); @ <h2>Changes to \ @ "%z(href("%R/whistory?name=%s",pW1->zWikiTitle))%h(pW1->zWikiTitle)</a>" \ |
︙ | ︙ | |||
1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 | style_set_current_feature("wiki"); style_header("Available Wiki Pages"); if( showAll ){ style_submenu_element("Active", "%R/wcontent"); }else{ style_submenu_element("All", "%R/wcontent?all=1"); } showCkBr = db_exists( "SELECT tag.tagname AS tn FROM tag JOIN tagxref USING(tagid) " "WHERE ( tn GLOB 'wiki-checkin/*' OR tn GLOB 'wiki-branch/*' ) " " AND TYPEOF(tagxref.value+0)='integer'" ); if( showCkBr ){ showCkBr = P("showckbr")!=0; style_submenu_checkbox("showckbr", "Show associated wikis", 0, 0); | > | 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 | style_set_current_feature("wiki"); style_header("Available Wiki Pages"); if( showAll ){ style_submenu_element("Active", "%R/wcontent"); }else{ style_submenu_element("All", "%R/wcontent?all=1"); } cgi_check_for_malice(); showCkBr = db_exists( "SELECT tag.tagname AS tn FROM tag JOIN tagxref USING(tagid) " "WHERE ( tn GLOB 'wiki-checkin/*' OR tn GLOB 'wiki-branch/*' ) " " AND TYPEOF(tagxref.value+0)='integer'" ); if( showCkBr ){ showCkBr = P("showckbr")!=0; style_submenu_checkbox("showckbr", "Show associated wikis", 0, 0); |
︙ | ︙ | |||
2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 | */ void wfind_page(void){ Stmt q; const char *zTitle; login_check_credentials(); if( !g.perm.RdWiki ){ login_needed(g.anon.RdWiki); return; } zTitle = PD("title","*"); style_set_current_feature("wiki"); style_header("Wiki Pages Found"); @ <ul> db_prepare(&q, "SELECT substr(tagname, 6, 1000) FROM tag WHERE tagname like 'wiki-%%%q%%'" " ORDER BY lower(tagname) /*sort*/" , zTitle); | > | 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 | */ void wfind_page(void){ Stmt q; const char *zTitle; login_check_credentials(); if( !g.perm.RdWiki ){ login_needed(g.anon.RdWiki); return; } zTitle = PD("title","*"); cgi_check_for_malice(); style_set_current_feature("wiki"); style_header("Wiki Pages Found"); @ <ul> db_prepare(&q, "SELECT substr(tagname, 6, 1000) FROM tag WHERE tagname like 'wiki-%%%q%%'" " ORDER BY lower(tagname) /*sort*/" , zTitle); |
︙ | ︙ |
Changes to src/xfer.c.
︙ | ︙ | |||
1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 | if( fossil_strcmp(PD("REQUEST_METHOD","POST"),"POST") ){ fossil_redirect_home(); } g.zLogin = "anonymous"; login_set_anon_nobody_capabilities(); login_check_credentials(); memset(&xfer, 0, sizeof(xfer)); blobarray_zero(xfer.aToken, count(xfer.aToken)); cgi_set_content_type(g.zContentType); cgi_reset_content(); if( db_schema_is_outofdate() ){ @ error database\sschema\sis\sout-of-date\son\sthe\sserver. return; | > | 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 | if( fossil_strcmp(PD("REQUEST_METHOD","POST"),"POST") ){ fossil_redirect_home(); } g.zLogin = "anonymous"; login_set_anon_nobody_capabilities(); login_check_credentials(); cgi_check_for_malice(); memset(&xfer, 0, sizeof(xfer)); blobarray_zero(xfer.aToken, count(xfer.aToken)); cgi_set_content_type(g.zContentType); cgi_reset_content(); if( db_schema_is_outofdate() ){ @ error database\sschema\sis\sout-of-date\son\sthe\sserver. return; |
︙ | ︙ |
Changes to src/zip.c.
︙ | ︙ | |||
1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 | @ <p>%s(zType) Archive named <b>%h(zName).%s(g.zPath)</b> @ holding the content of check-in <b>%h(zRid)</b>: @ <input type="submit" value="Download"> @ </form> style_finish_page(); return; } blob_zero(&zip); if( cache_read(&zip, zKey)==0 ){ zip_of_checkin(eType, rid, &zip, zName, pInclude, pExclude, 0); cache_write(&zip, zKey); } glob_free(pInclude); glob_free(pExclude); | > | 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 | @ <p>%s(zType) Archive named <b>%h(zName).%s(g.zPath)</b> @ holding the content of check-in <b>%h(zRid)</b>: @ <input type="submit" value="Download"> @ </form> style_finish_page(); return; } cgi_check_for_malice(); blob_zero(&zip); if( cache_read(&zip, zKey)==0 ){ zip_of_checkin(eType, rid, &zip, zName, pInclude, pExclude, 0); cache_write(&zip, zKey); } glob_free(pInclude); glob_free(pExclude); |
︙ | ︙ |