Fossil SCM
A couple of minor fixes for (not) showing associated wikis. This amends [25f43cc634].
Commit
3c2aba79a72f3df7bd8afff4740d4b9add29d584a3bdac86e094cc724f501941
Parent
e21f096c61e12ec…
1 file changed
+19
-13
+19
-13
| --- src/wiki.c | ||
| +++ src/wiki.c | ||
| @@ -21,10 +21,13 @@ | ||
| 21 | 21 | #include "config.h" |
| 22 | 22 | #include <assert.h> |
| 23 | 23 | #include <ctype.h> |
| 24 | 24 | #include "wiki.h" |
| 25 | 25 | |
| 26 | +#define has_prefix(literal_prfx, zStr) \ | |
| 27 | + (fossil_strncmp((zStr), "" literal_prfx, (sizeof literal_prfx)-1)==0) | |
| 28 | + | |
| 26 | 29 | /* |
| 27 | 30 | ** Return true if the input string is a well-formed wiki page name. |
| 28 | 31 | ** |
| 29 | 32 | ** Well-formed wiki page names do not begin or end with whitespace, |
| 30 | 33 | ** and do not contain tabs or other control characters and do not |
| @@ -420,22 +423,22 @@ | ||
| 420 | 423 | */ |
| 421 | 424 | int wiki_page_type(const char *zPageName){ |
| 422 | 425 | if( db_get_boolean("wiki-about",1)==0 ){ |
| 423 | 426 | return WIKITYPE_NORMAL; |
| 424 | 427 | }else |
| 425 | - if( sqlite3_strglob("checkin/*", zPageName)==0 | |
| 428 | + if( has_prefix("checkin/", zPageName) | |
| 426 | 429 | && db_exists("SELECT 1 FROM blob WHERE uuid=%Q",zPageName+8) |
| 427 | 430 | ){ |
| 428 | 431 | return WIKITYPE_CHECKIN; |
| 429 | 432 | }else |
| 430 | - if( sqlite3_strglob("branch/*", zPageName)==0 ){ | |
| 433 | + if( has_prefix("branch/", zPageName) ){ | |
| 431 | 434 | return WIKITYPE_BRANCH; |
| 432 | 435 | }else |
| 433 | - if( sqlite3_strglob("tag/*", zPageName)==0 ){ | |
| 436 | + if( has_prefix("tag/", zPageName) ){ | |
| 434 | 437 | return WIKITYPE_TAG; |
| 435 | 438 | }else |
| 436 | - if( sqlite3_strglob("ticket/*", zPageName)==0 ){ | |
| 439 | + if( has_prefix("ticket/", zPageName) ){ | |
| 437 | 440 | return WIKITYPE_TICKET; |
| 438 | 441 | } |
| 439 | 442 | return WIKITYPE_NORMAL; |
| 440 | 443 | } |
| 441 | 444 | |
| @@ -1987,11 +1990,12 @@ | ||
| 1987 | 1990 | style_submenu_element("All", "%R/wcontent?all=1"); |
| 1988 | 1991 | } |
| 1989 | 1992 | cgi_check_for_malice(); |
| 1990 | 1993 | showCkBr = db_exists( |
| 1991 | 1994 | "SELECT tag.tagname AS tn FROM tag JOIN tagxref USING(tagid) " |
| 1992 | - "WHERE ( tn GLOB 'wiki-checkin/*' OR tn GLOB 'wiki-branch/*' ) " | |
| 1995 | + "WHERE ( tn GLOB 'wiki-checkin/*' OR tn GLOB 'wiki-branch/*' OR " | |
| 1996 | + " tn GLOB 'wiki-tag/*' OR tn GLOB 'wiki-ticket/*' ) " | |
| 1993 | 1997 | " AND TYPEOF(tagxref.value+0)='integer'" ); |
| 1994 | 1998 | if( showCkBr ){ |
| 1995 | 1999 | showCkBr = P("showckbr")!=0; |
| 1996 | 2000 | style_submenu_checkbox("showckbr", "Show associated wikis", 0, 0); |
| 1997 | 2001 | } |
| @@ -2017,20 +2021,20 @@ | ||
| 2017 | 2021 | char *zAge; |
| 2018 | 2022 | int wcnt = db_column_int(&q, 4); |
| 2019 | 2023 | char *zWDisplayName; |
| 2020 | 2024 | |
| 2021 | 2025 | if( !showCkBr && |
| 2022 | - (sqlite3_strglob("checkin/*", zWName)==0 || | |
| 2023 | - sqlite3_strglob("branch/*", zWName)==0 || | |
| 2024 | - sqlite3_strglob("tag/*", zWName)==0 || | |
| 2025 | - sqlite3_strglob("ticket/*", zWName)==0) ){ | |
| 2026 | + (has_prefix("checkin/", zWName) || | |
| 2027 | + has_prefix("branch/", zWName) || | |
| 2028 | + has_prefix("tag/", zWName) || | |
| 2029 | + has_prefix("ticket/", zWName) )){ | |
| 2026 | 2030 | continue; |
| 2027 | 2031 | } |
| 2028 | - if( sqlite3_strglob("checkin/*", zWName)==0 ){ | |
| 2032 | + if( has_prefix("checkin/",zWName) || has_prefix("ticket/",zWName) ){ | |
| 2029 | 2033 | zWDisplayName = mprintf("%.25s...", zWName); |
| 2030 | 2034 | }else{ |
| 2031 | - zWDisplayName = mprintf("%s", zWName); | |
| 2035 | + zWDisplayName = fossil_strdup(zWName); | |
| 2032 | 2036 | } |
| 2033 | 2037 | if( wrid==0 ){ |
| 2034 | 2038 | if( !showAll ) continue; |
| 2035 | 2039 | @ <tr><td data-sortkey="%h(zSort)">\ |
| 2036 | 2040 | @ %z(href("%R/whistory?name=%T",zWName))<s>%h(zWDisplayName)</s></a></td> |
| @@ -2522,12 +2526,14 @@ | ||
| 2522 | 2526 | const int wrid = db_column_int(&q, 2); |
| 2523 | 2527 | if(!showAll && !wrid){ |
| 2524 | 2528 | continue; |
| 2525 | 2529 | } |
| 2526 | 2530 | if( !showCkBr && |
| 2527 | - (sqlite3_strglob("checkin/*", zName)==0 || | |
| 2528 | - sqlite3_strglob("branch/*", zName)==0) ){ | |
| 2531 | + (has_prefix("checkin/", zName) || | |
| 2532 | + has_prefix("branch/", zName) || | |
| 2533 | + has_prefix("tag/", zName) || | |
| 2534 | + has_prefix("ticket/", zName) ) ){ | |
| 2529 | 2535 | continue; |
| 2530 | 2536 | } |
| 2531 | 2537 | if( showIds ){ |
| 2532 | 2538 | const char *zUuid = db_column_text(&q, 1); |
| 2533 | 2539 | fossil_print("%s ",zUuid); |
| 2534 | 2540 |
| --- src/wiki.c | |
| +++ src/wiki.c | |
| @@ -21,10 +21,13 @@ | |
| 21 | #include "config.h" |
| 22 | #include <assert.h> |
| 23 | #include <ctype.h> |
| 24 | #include "wiki.h" |
| 25 | |
| 26 | /* |
| 27 | ** Return true if the input string is a well-formed wiki page name. |
| 28 | ** |
| 29 | ** Well-formed wiki page names do not begin or end with whitespace, |
| 30 | ** and do not contain tabs or other control characters and do not |
| @@ -420,22 +423,22 @@ | |
| 420 | */ |
| 421 | int wiki_page_type(const char *zPageName){ |
| 422 | if( db_get_boolean("wiki-about",1)==0 ){ |
| 423 | return WIKITYPE_NORMAL; |
| 424 | }else |
| 425 | if( sqlite3_strglob("checkin/*", zPageName)==0 |
| 426 | && db_exists("SELECT 1 FROM blob WHERE uuid=%Q",zPageName+8) |
| 427 | ){ |
| 428 | return WIKITYPE_CHECKIN; |
| 429 | }else |
| 430 | if( sqlite3_strglob("branch/*", zPageName)==0 ){ |
| 431 | return WIKITYPE_BRANCH; |
| 432 | }else |
| 433 | if( sqlite3_strglob("tag/*", zPageName)==0 ){ |
| 434 | return WIKITYPE_TAG; |
| 435 | }else |
| 436 | if( sqlite3_strglob("ticket/*", zPageName)==0 ){ |
| 437 | return WIKITYPE_TICKET; |
| 438 | } |
| 439 | return WIKITYPE_NORMAL; |
| 440 | } |
| 441 | |
| @@ -1987,11 +1990,12 @@ | |
| 1987 | style_submenu_element("All", "%R/wcontent?all=1"); |
| 1988 | } |
| 1989 | cgi_check_for_malice(); |
| 1990 | showCkBr = db_exists( |
| 1991 | "SELECT tag.tagname AS tn FROM tag JOIN tagxref USING(tagid) " |
| 1992 | "WHERE ( tn GLOB 'wiki-checkin/*' OR tn GLOB 'wiki-branch/*' ) " |
| 1993 | " AND TYPEOF(tagxref.value+0)='integer'" ); |
| 1994 | if( showCkBr ){ |
| 1995 | showCkBr = P("showckbr")!=0; |
| 1996 | style_submenu_checkbox("showckbr", "Show associated wikis", 0, 0); |
| 1997 | } |
| @@ -2017,20 +2021,20 @@ | |
| 2017 | char *zAge; |
| 2018 | int wcnt = db_column_int(&q, 4); |
| 2019 | char *zWDisplayName; |
| 2020 | |
| 2021 | if( !showCkBr && |
| 2022 | (sqlite3_strglob("checkin/*", zWName)==0 || |
| 2023 | sqlite3_strglob("branch/*", zWName)==0 || |
| 2024 | sqlite3_strglob("tag/*", zWName)==0 || |
| 2025 | sqlite3_strglob("ticket/*", zWName)==0) ){ |
| 2026 | continue; |
| 2027 | } |
| 2028 | if( sqlite3_strglob("checkin/*", zWName)==0 ){ |
| 2029 | zWDisplayName = mprintf("%.25s...", zWName); |
| 2030 | }else{ |
| 2031 | zWDisplayName = mprintf("%s", zWName); |
| 2032 | } |
| 2033 | if( wrid==0 ){ |
| 2034 | if( !showAll ) continue; |
| 2035 | @ <tr><td data-sortkey="%h(zSort)">\ |
| 2036 | @ %z(href("%R/whistory?name=%T",zWName))<s>%h(zWDisplayName)</s></a></td> |
| @@ -2522,12 +2526,14 @@ | |
| 2522 | const int wrid = db_column_int(&q, 2); |
| 2523 | if(!showAll && !wrid){ |
| 2524 | continue; |
| 2525 | } |
| 2526 | if( !showCkBr && |
| 2527 | (sqlite3_strglob("checkin/*", zName)==0 || |
| 2528 | sqlite3_strglob("branch/*", zName)==0) ){ |
| 2529 | continue; |
| 2530 | } |
| 2531 | if( showIds ){ |
| 2532 | const char *zUuid = db_column_text(&q, 1); |
| 2533 | fossil_print("%s ",zUuid); |
| 2534 |
| --- src/wiki.c | |
| +++ src/wiki.c | |
| @@ -21,10 +21,13 @@ | |
| 21 | #include "config.h" |
| 22 | #include <assert.h> |
| 23 | #include <ctype.h> |
| 24 | #include "wiki.h" |
| 25 | |
| 26 | #define has_prefix(literal_prfx, zStr) \ |
| 27 | (fossil_strncmp((zStr), "" literal_prfx, (sizeof literal_prfx)-1)==0) |
| 28 | |
| 29 | /* |
| 30 | ** Return true if the input string is a well-formed wiki page name. |
| 31 | ** |
| 32 | ** Well-formed wiki page names do not begin or end with whitespace, |
| 33 | ** and do not contain tabs or other control characters and do not |
| @@ -420,22 +423,22 @@ | |
| 423 | */ |
| 424 | int wiki_page_type(const char *zPageName){ |
| 425 | if( db_get_boolean("wiki-about",1)==0 ){ |
| 426 | return WIKITYPE_NORMAL; |
| 427 | }else |
| 428 | if( has_prefix("checkin/", zPageName) |
| 429 | && db_exists("SELECT 1 FROM blob WHERE uuid=%Q",zPageName+8) |
| 430 | ){ |
| 431 | return WIKITYPE_CHECKIN; |
| 432 | }else |
| 433 | if( has_prefix("branch/", zPageName) ){ |
| 434 | return WIKITYPE_BRANCH; |
| 435 | }else |
| 436 | if( has_prefix("tag/", zPageName) ){ |
| 437 | return WIKITYPE_TAG; |
| 438 | }else |
| 439 | if( has_prefix("ticket/", zPageName) ){ |
| 440 | return WIKITYPE_TICKET; |
| 441 | } |
| 442 | return WIKITYPE_NORMAL; |
| 443 | } |
| 444 | |
| @@ -1987,11 +1990,12 @@ | |
| 1990 | style_submenu_element("All", "%R/wcontent?all=1"); |
| 1991 | } |
| 1992 | cgi_check_for_malice(); |
| 1993 | showCkBr = db_exists( |
| 1994 | "SELECT tag.tagname AS tn FROM tag JOIN tagxref USING(tagid) " |
| 1995 | "WHERE ( tn GLOB 'wiki-checkin/*' OR tn GLOB 'wiki-branch/*' OR " |
| 1996 | " tn GLOB 'wiki-tag/*' OR tn GLOB 'wiki-ticket/*' ) " |
| 1997 | " AND TYPEOF(tagxref.value+0)='integer'" ); |
| 1998 | if( showCkBr ){ |
| 1999 | showCkBr = P("showckbr")!=0; |
| 2000 | style_submenu_checkbox("showckbr", "Show associated wikis", 0, 0); |
| 2001 | } |
| @@ -2017,20 +2021,20 @@ | |
| 2021 | char *zAge; |
| 2022 | int wcnt = db_column_int(&q, 4); |
| 2023 | char *zWDisplayName; |
| 2024 | |
| 2025 | if( !showCkBr && |
| 2026 | (has_prefix("checkin/", zWName) || |
| 2027 | has_prefix("branch/", zWName) || |
| 2028 | has_prefix("tag/", zWName) || |
| 2029 | has_prefix("ticket/", zWName) )){ |
| 2030 | continue; |
| 2031 | } |
| 2032 | if( has_prefix("checkin/",zWName) || has_prefix("ticket/",zWName) ){ |
| 2033 | zWDisplayName = mprintf("%.25s...", zWName); |
| 2034 | }else{ |
| 2035 | zWDisplayName = fossil_strdup(zWName); |
| 2036 | } |
| 2037 | if( wrid==0 ){ |
| 2038 | if( !showAll ) continue; |
| 2039 | @ <tr><td data-sortkey="%h(zSort)">\ |
| 2040 | @ %z(href("%R/whistory?name=%T",zWName))<s>%h(zWDisplayName)</s></a></td> |
| @@ -2522,12 +2526,14 @@ | |
| 2526 | const int wrid = db_column_int(&q, 2); |
| 2527 | if(!showAll && !wrid){ |
| 2528 | continue; |
| 2529 | } |
| 2530 | if( !showCkBr && |
| 2531 | (has_prefix("checkin/", zName) || |
| 2532 | has_prefix("branch/", zName) || |
| 2533 | has_prefix("tag/", zName) || |
| 2534 | has_prefix("ticket/", zName) ) ){ |
| 2535 | continue; |
| 2536 | } |
| 2537 | if( showIds ){ |
| 2538 | const char *zUuid = db_column_text(&q, 1); |
| 2539 | fossil_print("%s ",zUuid); |
| 2540 |