Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
| Comment: | Honor the "y=h" query option on the /search page even if help-search is disabled, but otherwise do not advertise help-search when it is disabled. |
|---|---|
| Timelines: | family | ancestors | descendants | both | trunk |
| Files: | files | file ages | folders |
| SHA3-256: |
2e9e3695ae6f837e668e8398c34c9eed |
| User & Date: | drh 2025-02-26 19:44:11.209 |
Context
|
2025-02-26
| ||
| 21:03 | Fix the comment formatter so that it does not crash with ill-formatted VT100 escapes. check-in: 2aa79ed752 user: drh tags: trunk | |
| 20:14 | Merge from trunk check-in: 17efadc96f user: brickviking tags: bv-infotool | |
| 19:44 | Honor the "y=h" query option on the /search page even if help-search is disabled, but otherwise do not advertise help-search when it is disabled. check-in: 2e9e3695ae user: drh tags: trunk | |
| 18:07 | Enhance the comment_print() subroutine so that it understands that VT100 escape codes are zero-width characters, and allocates text to lines accordingly. check-in: 32f954a1f2 user: drh tags: trunk | |
Changes
Changes to src/dispatch.c.
| ︙ | ︙ | |||
830 831 832 833 834 835 836 |
int rc;
const CmdOrPage *pCmd = 0;
style_set_current_feature("tkt");
style_header("Help: %s", zCmd);
style_submenu_element("Command-List", "%R/help");
| | | 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 |
int rc;
const CmdOrPage *pCmd = 0;
style_set_current_feature("tkt");
style_header("Help: %s", zCmd);
style_submenu_element("Command-List", "%R/help");
if( search_restrict(SRCH_HELP)!=0 ){
style_submenu_element("Search","%R/search?y=h");
}
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> */
@ <h1>The "%h(zCmd)" page:</h1>
|
| ︙ | ︙ |
Changes to src/forum.c.
| ︙ | ︙ | |||
1925 1926 1927 1928 1929 1930 1931 |
Stmt q;
int iLimit = 0, iOfst, iCnt;
int srchFlags;
const int isSearch = P("s")!=0;
char const *zLimit = 0;
login_check_credentials();
| | | 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 |
Stmt q;
int iLimit = 0, iOfst, iCnt;
int srchFlags;
const int isSearch = P("s")!=0;
char const *zLimit = 0;
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%s", db_get("forum-title","Forum"),
|
| ︙ | ︙ |
Changes to src/search.c.
| ︙ | ︙ | |||
737 738 739 740 741 742 743 |
if( srchFlags==0 ) srchFlags = SRCH_CKIN;
db_find_and_open_repository(0, 0);
verify_all_options();
if( g.argc<3 ) return;
login_set_capabilities("s", 0);
| | | 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 |
if( srchFlags==0 ) srchFlags = SRCH_CKIN;
db_find_and_open_repository(0, 0);
verify_all_options();
if( g.argc<3 ) return;
login_set_capabilities("s", 0);
if( search_restrict(srchFlags)==0 && (srchFlags & SRCH_HELP)==0 ){
const char *zC1 = 0, *zPlural = "s";
if( srchFlags & SRCH_TECHNOTE ){ zC1 = "technote"; }
if( srchFlags & SRCH_TKT ){ zC1 = "ticket"; }
if( srchFlags & SRCH_FORUM ){ zC1 = "forum"; zPlural = ""; }
if( srchFlags & SRCH_DOC ){ zC1 = "document"; }
if( srchFlags & SRCH_WIKI ){ zC1 = "wiki"; zPlural = ""; }
if( srchFlags & SRCH_CKIN ){ zC1 = "check-in"; }
|
| ︙ | ︙ | |||
859 860 861 862 863 864 865 | ** Remove bits from srchFlags which are disallowed by either the ** current server configuration or by user permissions. Return ** the revised search flags mask. ** ** If bFlex is true, that means allow through the SRCH_HELP option ** even if it is not explicitly enabled. */ | | | 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 |
** Remove bits from srchFlags which are disallowed by either the
** current server configuration or by user permissions. Return
** the revised search flags mask.
**
** If bFlex is true, that means allow through the SRCH_HELP option
** even if it is not explicitly enabled.
*/
unsigned int search_restrict(unsigned int srchFlags){
static unsigned int knownGood = 0;
static unsigned int knownBad = 0;
static const struct { unsigned m; const char *zKey; } aSetng[] = {
{ SRCH_CKIN, "search-ci" },
{ SRCH_DOC, "search-doc" },
{ SRCH_TKT, "search-tkt" },
{ SRCH_WIKI, "search-wiki" },
|
| ︙ | ︙ | |||
886 887 888 889 890 891 892 |
if( ((knownGood|knownBad) & m)!=0 ) continue;
if( db_get_boolean(aSetng[i].zKey,0) ){
knownGood |= m;
}else{
knownBad |= m;
}
}
| < | 886 887 888 889 890 891 892 893 894 895 896 897 898 899 |
if( ((knownGood|knownBad) & m)!=0 ) continue;
if( db_get_boolean(aSetng[i].zKey,0) ){
knownGood |= m;
}else{
knownBad |= m;
}
}
return srchFlags & ~knownBad;
}
/*
** When this routine is called, there already exists a table
**
** x(label,url,score,id,snip).
|
| ︙ | ︙ | |||
1294 1295 1296 1297 1298 1299 1300 |
Stmt q;
int nRow = 0;
int nLimit = db_get_int("search-limit", 100);
if( P("searchlimit")!=0 ){
nLimit = atoi(P("searchlimit"));
}
| | | 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 |
Stmt q;
int nRow = 0;
int nLimit = db_get_int("search-limit", 100);
if( P("searchlimit")!=0 ){
nLimit = atoi(P("searchlimit"));
}
srchFlags = search_restrict(srchFlags) | (srchFlags & SRCH_HELP);
if( srchFlags==0 ) return 0;
search_sql_setup(g.db);
add_content_sql_commands(g.db);
db_multi_exec(
"CREATE TEMP TABLE x(label,url,score,id,date,snip);"
);
if( !search_index_exists() ){
|
| ︙ | ︙ | |||
1363 1364 1365 1366 1367 1368 1369 | ** 0x01 If the y= query parameter is present, use it as an addition ** restriction what to search. ** ** 0x02 Show nothing if search is disabled. ** ** Return true if there are search results. */ | | > > > > > | > | | > | | > > > > < < | > > | < | | | 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 |
** 0x01 If the y= query parameter is present, use it as an addition
** restriction what to search.
**
** 0x02 Show nothing if search is disabled.
**
** Return true if there are search results.
*/
int search_screen(unsigned srchAllowed, int mFlags){
const char *zType = 0;
const char *zClass = 0;
const char *zDisable1;
const char *zDisable2;
const char *zPattern;
int fDebug = PB("debug");
int haveResult = 0;
int srchThisTime;
const char *zY = PD("y","all");
if( zY[0]=='h' && zY[1]==0 ){
srchAllowed = search_restrict(srchAllowed) | (srchAllowed & SRCH_HELP);
}else{
srchAllowed = search_restrict(srchAllowed);
}
switch( srchAllowed ){
case SRCH_CKIN: zType = " Check-ins"; zClass = "Ckin"; break;
case SRCH_DOC: zType = " Docs"; zClass = "Doc"; break;
case SRCH_TKT: zType = " Tickets"; zClass = "Tkt"; break;
case SRCH_WIKI: zType = " Wiki"; zClass = "Wiki"; break;
case SRCH_TECHNOTE: zType = " Tech Notes"; zClass = "Note"; break;
case SRCH_FORUM: zType = " Forum"; zClass = "Frm"; break;
case SRCH_HELP: zType = " Help"; zClass = "Hlp"; break;
}
if( srchAllowed==0 ){
if( mFlags & 0x02 ) return 0;
zDisable1 = " disabled";
zDisable2 = " disabled";
zPattern = "";
}else{
zDisable1 = ""; /* Was: " autofocus" */
zDisable2 = "";
zPattern = PD("s","");
}
@ <form method='GET' action='%R/%T(g.zPath)'>
if( zClass ){
@ <div class='searchForm searchForm%s(zClass)'>
}else{
@ <div class='searchForm'>
}
@ <input type="text" name="s" size="40" value="%h(zPattern)"%s(zDisable1)>
srchThisTime = srchAllowed;
if( (mFlags & 0x01)!=0 && (srchAllowed & (srchAllowed-1))!=0 ){
static const struct {
const char *z;
const char *zNm;
unsigned m;
} aY[] = {
{ "all", "All", SRCH_ALL },
{ "c", "Check-ins", SRCH_CKIN },
{ "d", "Docs", SRCH_DOC },
{ "t", "Tickets", SRCH_TKT },
{ "w", "Wiki", SRCH_WIKI },
{ "e", "Tech Notes", SRCH_TECHNOTE },
{ "f", "Forum", SRCH_FORUM },
{ "h", "Help", SRCH_HELP },
};
int i;
@ <select size='1' name='y'>
for(i=0; i<count(aY); i++){
if( (aY[i].m & srchAllowed)==0 ) continue;
if( aY[i].m==SRCH_HELP && fossil_strcmp(zY,"h")!=0
&& search_restrict(SRCH_HELP)==0 ) continue;
cgi_printf("<option value='%s'", aY[i].z);
if( fossil_strcmp(zY,aY[i].z)==0 ){
srchThisTime &= aY[i].m;
cgi_printf(" selected");
}
cgi_printf(">%s</option>\n", aY[i].zNm);
}
@ </select>
}
if( fDebug ){
@ <input type="hidden" name="debug" value="1">
}
@ <input type="submit" value="Search%s(zType)"%s(zDisable2)>
if( srchAllowed==0 && srchThisTime==0 ){
@ <p class="generalError">Search is disabled</p>
}
@ </div></form>
while( fossil_isspace(zPattern[0]) ) zPattern++;
if( zPattern[0] ){
if( zClass ){
@ <div class='searchResult searchResult%s(zClass)'>
}else{
@ <div class='searchResult'>
}
if( search_run_and_output(zPattern, srchThisTime, fDebug)==0 ){
@ <p class='searchEmpty'>No matches for: <span>%h(zPattern)</span></p>
}
@ </div>
haveResult = 1;
}
return haveResult;
}
|
| ︙ | ︙ | |||
2243 2244 2245 2246 2247 2248 2249 |
** Construct, prepopulate, and then update the full-text index.
*/
void search_rebuild_index(void){
fossil_print("rebuilding the search index...");
fflush(stdout);
search_create_index();
search_fill_index();
| | | 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 |
** Construct, prepopulate, and then update the full-text index.
*/
void search_rebuild_index(void){
fossil_print("rebuilding the search index...");
fflush(stdout);
search_create_index();
search_fill_index();
search_update_index(search_restrict(SRCH_ALL));
if( db_table_exists("repository","chat") ){
chat_rebuild_index(1);
}
fossil_print(" done\n");
}
/*
|
| ︙ | ︙ |
Changes to src/setup.c.
| ︙ | ︙ | |||
2263 2264 2265 2266 2267 2268 2269 |
search_drop_index();
}else if( P("fts1") ){
const char *zTokenizer = PD("ftstok","off");
search_set_tokenizer(zTokenizer);
search_drop_index();
search_create_index();
search_fill_index();
| | | 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 |
search_drop_index();
}else if( P("fts1") ){
const char *zTokenizer = PD("ftstok","off");
search_set_tokenizer(zTokenizer);
search_drop_index();
search_create_index();
search_fill_index();
search_update_index(search_restrict(SRCH_ALL));
}
if( search_index_exists() ){
int pgsz = db_int64(0, "PRAGMA repository.page_size;");
i64 nTotal = db_int64(0, "PRAGMA repository.page_count;")*pgsz;
i64 nFts = db_int64(0, "SELECT count(*) FROM dbstat"
" WHERE schema='repository'"
" AND name LIKE 'fts%%'")*pgsz;
|
| ︙ | ︙ |
Changes to src/sitemap.c.
| ︙ | ︙ | |||
62 63 64 65 66 67 68 |
if( P("popup")!=0 ){
/* The "popup" query parameter
** then disable anti-robot defenses */
isPopup = 1;
g.perm.Hyperlink = 1;
g.jsHref = 0;
}
| | | 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
if( P("popup")!=0 ){
/* The "popup" query parameter
** then disable anti-robot defenses */
isPopup = 1;
g.perm.Hyperlink = 1;
g.jsHref = 0;
}
srchFlags = search_restrict(SRCH_ALL);
if( !isPopup ){
style_header("Site Map");
style_adunit_config(ADUNIT_RIGHT_OK);
}
@ <ul id="sitemap" class="columns" style="column-width:20em">
if( (e&1)==0 ){
|
| ︙ | ︙ |
Changes to src/th_main.c.
| ︙ | ︙ | |||
913 914 915 916 917 918 919 |
Th_Interp *interp,
void *p,
int argc,
const char **argv,
int *argl
){
int rc = 1, i, j;
| | | 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 |
Th_Interp *interp,
void *p,
int argc,
const char **argv,
int *argl
){
int rc = 1, i, j;
unsigned int searchCap = search_restrict(SRCH_ALL);
if( argc<2 ){
return Th_WrongNumArgs(interp, "hascap STRING ...");
}
for(i=1; i<argc && rc; i++){
int match = 0;
for(j=0; j<argl[i]; j++){
switch( argv[i][j] ){
|
| ︙ | ︙ |
Changes to src/timeline.c.
| ︙ | ︙ | |||
3003 3004 3005 3006 3007 3008 3009 |
blob_zero(&cond);
}
if( showSql ){
db_append_dml_to_blob(0);
@ <pre>%h(blob_str(&allSql))</pre>
blob_reset(&allSql);
}
| | | 3003 3004 3005 3006 3007 3008 3009 3010 3011 3012 3013 3014 3015 3016 3017 |
blob_zero(&cond);
}
if( showSql ){
db_append_dml_to_blob(0);
@ <pre>%h(blob_str(&allSql))</pre>
blob_reset(&allSql);
}
if( search_restrict(SRCH_CKIN)!=0 ){
style_submenu_element("Search", "%R/search?y=c");
}
if( advancedMenu ){
style_submenu_element("Basic", "%s",
url_render(&url, "advm", "0", "udc", "1"));
}else{
style_submenu_element("Advanced", "%s",
|
| ︙ | ︙ |
Changes to src/tkt.c.
| ︙ | ︙ | |||
1856 1857 1858 1859 1860 1861 1862 |
#define T_ALL_BUT(x) (T_ALL&~(x))
#endif
/*
** Add some standard submenu elements for ticket screens.
*/
void ticket_standard_submenu(unsigned int ok){
| | | | 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 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 |
#define T_ALL_BUT(x) (T_ALL&~(x))
#endif
/*
** Add some standard submenu elements for ticket screens.
*/
void ticket_standard_submenu(unsigned int ok){
if( (ok & T_SRCH)!=0 && search_restrict(SRCH_TKT)!=0 ){
style_submenu_element("Search", "%R/tktsrch");
}
if( (ok & T_REPLIST)!=0 ){
style_submenu_element("Reports", "%R/reportlist");
}
if( (ok & T_NEW)!=0 && g.anon.NewTkt ){
style_submenu_element("New", "%R/tktnew");
}
}
/*
** WEBPAGE: ticket
**
** This is intended to be the primary "Ticket" page. Render as
** either ticket-search (if search is enabled) or as the
** /reportlist page (if ticket search is disabled).
*/
void tkt_home_page(void){
login_check_credentials();
if( search_restrict(SRCH_TKT)!=0 ){
tkt_srchpage();
}else{
view_list();
}
}
/*
|
| ︙ | ︙ |
Changes to src/wiki.c.
| ︙ | ︙ | |||
330 331 332 333 334 335 336 |
#define W_ALL 0x0001f
#define W_ALL_BUT(x) (W_ALL&~(x))
/*
** Add some standard submenu elements for wiki screens.
*/
static void wiki_standard_submenu(unsigned int ok){
| | | 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 |
#define W_ALL 0x0001f
#define W_ALL_BUT(x) (W_ALL&~(x))
/*
** Add some standard submenu elements for wiki screens.
*/
static void wiki_standard_submenu(unsigned int ok){
if( (ok & W_SRCH)!=0 && search_restrict(SRCH_WIKI)!=0 ){
style_submenu_element("Search", "%R/wikisrch");
}
if( (ok & W_LIST)!=0 ){
style_submenu_element("List", "%R/wcontent");
}
if( (ok & W_HELP)!=0 ){
style_submenu_element("Help", "%R/wikihelp");
|
| ︙ | ︙ | |||
377 378 379 380 381 382 383 |
@ <li> %z(href("%R/wcontent"))List of All Wiki Pages</a>
@ available on this server.</li>
@ <li> %z(href("%R/timeline?y=e"))List of All Tech-notes</a>
@ available on this server.</li>
if( g.perm.ModWiki ){
@ <li> %z(href("%R/modreq"))Tend to pending moderation requests</a></li>
}
| | | 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 |
@ <li> %z(href("%R/wcontent"))List of All Wiki Pages</a>
@ available on this server.</li>
@ <li> %z(href("%R/timeline?y=e"))List of All Tech-notes</a>
@ available on this server.</li>
if( g.perm.ModWiki ){
@ <li> %z(href("%R/modreq"))Tend to pending moderation requests</a></li>
}
if( search_restrict(SRCH_WIKI)!=0 ){
@ <li> %z(href("%R/wikisrch"))Search</a> for wiki pages containing key
@ words</li>
}
@ </ul>
style_finish_page();
return;
}
|
| ︙ | ︙ | |||
578 579 580 581 582 583 584 |
login_check_credentials();
if( !g.perm.RdWiki ){ login_needed(g.anon.RdWiki); return; }
zPageName = P("name");
(void)P("s")/*for cgi_check_for_malice(). "s" == search stringy*/;
cgi_check_for_malice();
if( zPageName==0 ){
| | | 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 |
login_check_credentials();
if( !g.perm.RdWiki ){ login_needed(g.anon.RdWiki); return; }
zPageName = P("name");
(void)P("s")/*for cgi_check_for_malice(). "s" == search stringy*/;
cgi_check_for_malice();
if( zPageName==0 ){
if( search_restrict(SRCH_WIKI)!=0 ){
wiki_srchpage();
}else{
wiki_helppage();
}
return;
}
if( check_name(zPageName) ) return;
|
| ︙ | ︙ |