Fossil SCM
Back out [a402dd2a888d6d74] (wiki title search), as it causes all searches to fail for reasons as yet undetermined.
Commit
48af08bd48a83f92f00fd65c60e034eb78c67b12ab2fe17cac489da45da1373f
Parent
c8fda6a62cc5c6e…
1 file changed
+26
-28
+26
-28
| --- src/search.c | ||
| +++ src/search.c | ||
| @@ -1229,52 +1229,50 @@ | ||
| 1229 | 1229 | |
| 1230 | 1230 | /* |
| 1231 | 1231 | ** This is a helper function for search_stext(). Writing into pOut |
| 1232 | 1232 | ** the search text obtained from pIn according to zMimetype. |
| 1233 | 1233 | ** |
| 1234 | -** If a title is not specified in zTitle (e.g. for wiki pages that do not | |
| 1235 | -** include the title in the body), it is determined from the page content. | |
| 1236 | -** | |
| 1237 | 1234 | ** The title of the document is the first line of text. All subsequent |
| 1238 | 1235 | ** lines are the body. If the document has no title, the first line |
| 1239 | 1236 | ** is blank. |
| 1240 | 1237 | */ |
| 1241 | 1238 | static void get_stext_by_mimetype( |
| 1242 | 1239 | Blob *pIn, |
| 1243 | 1240 | const char *zMimetype, |
| 1244 | - const char *zTitle, | |
| 1245 | 1241 | Blob *pOut |
| 1246 | 1242 | ){ |
| 1247 | 1243 | Blob html, title; |
| 1248 | - Blob *pHtml = &html; | |
| 1249 | 1244 | blob_init(&html, 0, 0); |
| 1250 | - if( zTitle==0 ){ | |
| 1251 | - blob_init(&title, 0, 0); | |
| 1252 | - }else{ | |
| 1253 | - blob_init(&title, zTitle, -1); | |
| 1254 | - } | |
| 1245 | + blob_init(&title, 0, 0); | |
| 1255 | 1246 | if( zMimetype==0 ) zMimetype = "text/plain"; |
| 1256 | 1247 | if( fossil_strcmp(zMimetype,"text/x-fossil-wiki")==0 ){ |
| 1257 | - if( blob_size(&title) ){ | |
| 1258 | - wiki_convert(pIn, &html, 0); | |
| 1259 | - }else{ | |
| 1260 | - Blob tail; | |
| 1261 | - blob_init(&tail, 0, 0); | |
| 1262 | - wiki_find_title(pIn, &title, &tail); | |
| 1248 | + Blob tail; | |
| 1249 | + blob_init(&tail, 0, 0); | |
| 1250 | + if( wiki_find_title(pIn, &title, &tail) ){ | |
| 1251 | + blob_appendf(pOut, "%s\n", blob_str(&title)); | |
| 1263 | 1252 | wiki_convert(&tail, &html, 0); |
| 1264 | 1253 | blob_reset(&tail); |
| 1254 | + }else{ | |
| 1255 | + blob_append(pOut, "\n", 1); | |
| 1256 | + wiki_convert(pIn, &html, 0); | |
| 1265 | 1257 | } |
| 1258 | + html_to_plaintext(blob_str(&html), pOut); | |
| 1266 | 1259 | }else if( fossil_strcmp(zMimetype,"text/x-markdown")==0 ){ |
| 1267 | - markdown_to_html(pIn, blob_size(&title) ? NULL : &title, &html); | |
| 1260 | + markdown_to_html(pIn, &title, &html); | |
| 1261 | + if( blob_size(&title) ){ | |
| 1262 | + blob_appendf(pOut, "%s\n", blob_str(&title)); | |
| 1263 | + }else{ | |
| 1264 | + blob_append(pOut, "\n", 1); | |
| 1265 | + } | |
| 1266 | + html_to_plaintext(blob_str(&html), pOut); | |
| 1268 | 1267 | }else if( fossil_strcmp(zMimetype,"text/html")==0 ){ |
| 1269 | - if( blob_size(&title)==0 ) doc_is_embedded_html(pIn, &title); | |
| 1270 | - pHtml = pIn; | |
| 1271 | - } | |
| 1272 | - blob_appendf(pOut, "%s\n", blob_str(&title)); | |
| 1273 | - if( blob_size(pHtml) ){ | |
| 1274 | - html_to_plaintext(blob_str(pHtml), pOut); | |
| 1268 | + if( doc_is_embedded_html(pIn, &title) ){ | |
| 1269 | + blob_appendf(pOut, "%s\n", blob_str(&title)); | |
| 1270 | + } | |
| 1271 | + html_to_plaintext(blob_str(pIn), pOut); | |
| 1275 | 1272 | }else{ |
| 1273 | + blob_append(pOut, "\n", 1); | |
| 1276 | 1274 | blob_append(pOut, blob_buffer(pIn), blob_size(pIn)); |
| 1277 | 1275 | } |
| 1278 | 1276 | blob_reset(&html); |
| 1279 | 1277 | blob_reset(&title); |
| 1280 | 1278 | } |
| @@ -1307,11 +1305,11 @@ | ||
| 1307 | 1305 | blob_appendf(pAccum, "%s: %s |\n", zColName, db_column_text(pQuery,i)); |
| 1308 | 1306 | }else{ |
| 1309 | 1307 | Blob txt; |
| 1310 | 1308 | blob_init(&txt, db_column_text(pQuery,i), -1); |
| 1311 | 1309 | blob_appendf(pAccum, "%s: ", zColName); |
| 1312 | - get_stext_by_mimetype(&txt, zMime, NULL, pAccum); | |
| 1310 | + get_stext_by_mimetype(&txt, zMime, pAccum); | |
| 1313 | 1311 | blob_append(pAccum, " |", 2); |
| 1314 | 1312 | blob_reset(&txt); |
| 1315 | 1313 | } |
| 1316 | 1314 | } |
| 1317 | 1315 | } |
| @@ -1346,11 +1344,11 @@ | ||
| 1346 | 1344 | switch( cType ){ |
| 1347 | 1345 | case 'd': { /* Documents */ |
| 1348 | 1346 | Blob doc; |
| 1349 | 1347 | content_get(rid, &doc); |
| 1350 | 1348 | blob_to_utf8_no_bom(&doc, 0); |
| 1351 | - get_stext_by_mimetype(&doc, mimetype_from_name(zName), NULL, pOut); | |
| 1349 | + get_stext_by_mimetype(&doc, mimetype_from_name(zName), pOut); | |
| 1352 | 1350 | blob_reset(&doc); |
| 1353 | 1351 | break; |
| 1354 | 1352 | } |
| 1355 | 1353 | case 'f': /* Forum messages */ |
| 1356 | 1354 | case 'e': /* Tech Notes */ |
| @@ -1368,11 +1366,11 @@ | ||
| 1368 | 1366 | blob_appendf(&wiki, "From %s:\n\n%s", pWiki->zUser, pWiki->zWiki); |
| 1369 | 1367 | }else{ |
| 1370 | 1368 | blob_init(&wiki, pWiki->zWiki, -1); |
| 1371 | 1369 | } |
| 1372 | 1370 | get_stext_by_mimetype(&wiki, wiki_filter_mimetypes(pWiki->zMimetype), |
| 1373 | - cType=='w' ? pWiki->zWikiTitle : NULL, pOut); | |
| 1371 | + pOut); | |
| 1374 | 1372 | blob_reset(&wiki); |
| 1375 | 1373 | manifest_destroy(pWiki); |
| 1376 | 1374 | break; |
| 1377 | 1375 | } |
| 1378 | 1376 | case 'c': { /* Check-in Comments */ |
| @@ -1398,11 +1396,11 @@ | ||
| 1398 | 1396 | db_column_blob(&q, 0, pOut); |
| 1399 | 1397 | }else{ |
| 1400 | 1398 | Blob x; |
| 1401 | 1399 | blob_init(&x,0,0); |
| 1402 | 1400 | db_column_blob(&q, 0, &x); |
| 1403 | - get_stext_by_mimetype(&x, "text/x-fossil-wiki", NULL, pOut); | |
| 1401 | + get_stext_by_mimetype(&x, "text/x-fossil-wiki", pOut); | |
| 1404 | 1402 | blob_reset(&x); |
| 1405 | 1403 | } |
| 1406 | 1404 | } |
| 1407 | 1405 | db_reset(&q); |
| 1408 | 1406 | break; |
| @@ -1509,11 +1507,11 @@ | ||
| 1509 | 1507 | Blob in, out; |
| 1510 | 1508 | db_find_and_open_repository(0,0); |
| 1511 | 1509 | if( g.argc!=4 ) usage("FILENAME MIMETYPE"); |
| 1512 | 1510 | blob_read_from_file(&in, g.argv[2], ExtFILE); |
| 1513 | 1511 | blob_init(&out, 0, 0); |
| 1514 | - get_stext_by_mimetype(&in, g.argv[3], NULL, &out); | |
| 1512 | + get_stext_by_mimetype(&in, g.argv[3], &out); | |
| 1515 | 1513 | fossil_print("%s\n",blob_str(&out)); |
| 1516 | 1514 | blob_reset(&in); |
| 1517 | 1515 | blob_reset(&out); |
| 1518 | 1516 | } |
| 1519 | 1517 | |
| 1520 | 1518 |
| --- src/search.c | |
| +++ src/search.c | |
| @@ -1229,52 +1229,50 @@ | |
| 1229 | |
| 1230 | /* |
| 1231 | ** This is a helper function for search_stext(). Writing into pOut |
| 1232 | ** the search text obtained from pIn according to zMimetype. |
| 1233 | ** |
| 1234 | ** If a title is not specified in zTitle (e.g. for wiki pages that do not |
| 1235 | ** include the title in the body), it is determined from the page content. |
| 1236 | ** |
| 1237 | ** The title of the document is the first line of text. All subsequent |
| 1238 | ** lines are the body. If the document has no title, the first line |
| 1239 | ** is blank. |
| 1240 | */ |
| 1241 | static void get_stext_by_mimetype( |
| 1242 | Blob *pIn, |
| 1243 | const char *zMimetype, |
| 1244 | const char *zTitle, |
| 1245 | Blob *pOut |
| 1246 | ){ |
| 1247 | Blob html, title; |
| 1248 | Blob *pHtml = &html; |
| 1249 | blob_init(&html, 0, 0); |
| 1250 | if( zTitle==0 ){ |
| 1251 | blob_init(&title, 0, 0); |
| 1252 | }else{ |
| 1253 | blob_init(&title, zTitle, -1); |
| 1254 | } |
| 1255 | if( zMimetype==0 ) zMimetype = "text/plain"; |
| 1256 | if( fossil_strcmp(zMimetype,"text/x-fossil-wiki")==0 ){ |
| 1257 | if( blob_size(&title) ){ |
| 1258 | wiki_convert(pIn, &html, 0); |
| 1259 | }else{ |
| 1260 | Blob tail; |
| 1261 | blob_init(&tail, 0, 0); |
| 1262 | wiki_find_title(pIn, &title, &tail); |
| 1263 | wiki_convert(&tail, &html, 0); |
| 1264 | blob_reset(&tail); |
| 1265 | } |
| 1266 | }else if( fossil_strcmp(zMimetype,"text/x-markdown")==0 ){ |
| 1267 | markdown_to_html(pIn, blob_size(&title) ? NULL : &title, &html); |
| 1268 | }else if( fossil_strcmp(zMimetype,"text/html")==0 ){ |
| 1269 | if( blob_size(&title)==0 ) doc_is_embedded_html(pIn, &title); |
| 1270 | pHtml = pIn; |
| 1271 | } |
| 1272 | blob_appendf(pOut, "%s\n", blob_str(&title)); |
| 1273 | if( blob_size(pHtml) ){ |
| 1274 | html_to_plaintext(blob_str(pHtml), pOut); |
| 1275 | }else{ |
| 1276 | blob_append(pOut, blob_buffer(pIn), blob_size(pIn)); |
| 1277 | } |
| 1278 | blob_reset(&html); |
| 1279 | blob_reset(&title); |
| 1280 | } |
| @@ -1307,11 +1305,11 @@ | |
| 1307 | blob_appendf(pAccum, "%s: %s |\n", zColName, db_column_text(pQuery,i)); |
| 1308 | }else{ |
| 1309 | Blob txt; |
| 1310 | blob_init(&txt, db_column_text(pQuery,i), -1); |
| 1311 | blob_appendf(pAccum, "%s: ", zColName); |
| 1312 | get_stext_by_mimetype(&txt, zMime, NULL, pAccum); |
| 1313 | blob_append(pAccum, " |", 2); |
| 1314 | blob_reset(&txt); |
| 1315 | } |
| 1316 | } |
| 1317 | } |
| @@ -1346,11 +1344,11 @@ | |
| 1346 | switch( cType ){ |
| 1347 | case 'd': { /* Documents */ |
| 1348 | Blob doc; |
| 1349 | content_get(rid, &doc); |
| 1350 | blob_to_utf8_no_bom(&doc, 0); |
| 1351 | get_stext_by_mimetype(&doc, mimetype_from_name(zName), NULL, pOut); |
| 1352 | blob_reset(&doc); |
| 1353 | break; |
| 1354 | } |
| 1355 | case 'f': /* Forum messages */ |
| 1356 | case 'e': /* Tech Notes */ |
| @@ -1368,11 +1366,11 @@ | |
| 1368 | blob_appendf(&wiki, "From %s:\n\n%s", pWiki->zUser, pWiki->zWiki); |
| 1369 | }else{ |
| 1370 | blob_init(&wiki, pWiki->zWiki, -1); |
| 1371 | } |
| 1372 | get_stext_by_mimetype(&wiki, wiki_filter_mimetypes(pWiki->zMimetype), |
| 1373 | cType=='w' ? pWiki->zWikiTitle : NULL, pOut); |
| 1374 | blob_reset(&wiki); |
| 1375 | manifest_destroy(pWiki); |
| 1376 | break; |
| 1377 | } |
| 1378 | case 'c': { /* Check-in Comments */ |
| @@ -1398,11 +1396,11 @@ | |
| 1398 | db_column_blob(&q, 0, pOut); |
| 1399 | }else{ |
| 1400 | Blob x; |
| 1401 | blob_init(&x,0,0); |
| 1402 | db_column_blob(&q, 0, &x); |
| 1403 | get_stext_by_mimetype(&x, "text/x-fossil-wiki", NULL, pOut); |
| 1404 | blob_reset(&x); |
| 1405 | } |
| 1406 | } |
| 1407 | db_reset(&q); |
| 1408 | break; |
| @@ -1509,11 +1507,11 @@ | |
| 1509 | Blob in, out; |
| 1510 | db_find_and_open_repository(0,0); |
| 1511 | if( g.argc!=4 ) usage("FILENAME MIMETYPE"); |
| 1512 | blob_read_from_file(&in, g.argv[2], ExtFILE); |
| 1513 | blob_init(&out, 0, 0); |
| 1514 | get_stext_by_mimetype(&in, g.argv[3], NULL, &out); |
| 1515 | fossil_print("%s\n",blob_str(&out)); |
| 1516 | blob_reset(&in); |
| 1517 | blob_reset(&out); |
| 1518 | } |
| 1519 | |
| 1520 |
| --- src/search.c | |
| +++ src/search.c | |
| @@ -1229,52 +1229,50 @@ | |
| 1229 | |
| 1230 | /* |
| 1231 | ** This is a helper function for search_stext(). Writing into pOut |
| 1232 | ** the search text obtained from pIn according to zMimetype. |
| 1233 | ** |
| 1234 | ** The title of the document is the first line of text. All subsequent |
| 1235 | ** lines are the body. If the document has no title, the first line |
| 1236 | ** is blank. |
| 1237 | */ |
| 1238 | static void get_stext_by_mimetype( |
| 1239 | Blob *pIn, |
| 1240 | const char *zMimetype, |
| 1241 | Blob *pOut |
| 1242 | ){ |
| 1243 | Blob html, title; |
| 1244 | blob_init(&html, 0, 0); |
| 1245 | blob_init(&title, 0, 0); |
| 1246 | if( zMimetype==0 ) zMimetype = "text/plain"; |
| 1247 | if( fossil_strcmp(zMimetype,"text/x-fossil-wiki")==0 ){ |
| 1248 | Blob tail; |
| 1249 | blob_init(&tail, 0, 0); |
| 1250 | if( wiki_find_title(pIn, &title, &tail) ){ |
| 1251 | blob_appendf(pOut, "%s\n", blob_str(&title)); |
| 1252 | wiki_convert(&tail, &html, 0); |
| 1253 | blob_reset(&tail); |
| 1254 | }else{ |
| 1255 | blob_append(pOut, "\n", 1); |
| 1256 | wiki_convert(pIn, &html, 0); |
| 1257 | } |
| 1258 | html_to_plaintext(blob_str(&html), pOut); |
| 1259 | }else if( fossil_strcmp(zMimetype,"text/x-markdown")==0 ){ |
| 1260 | markdown_to_html(pIn, &title, &html); |
| 1261 | if( blob_size(&title) ){ |
| 1262 | blob_appendf(pOut, "%s\n", blob_str(&title)); |
| 1263 | }else{ |
| 1264 | blob_append(pOut, "\n", 1); |
| 1265 | } |
| 1266 | html_to_plaintext(blob_str(&html), pOut); |
| 1267 | }else if( fossil_strcmp(zMimetype,"text/html")==0 ){ |
| 1268 | if( doc_is_embedded_html(pIn, &title) ){ |
| 1269 | blob_appendf(pOut, "%s\n", blob_str(&title)); |
| 1270 | } |
| 1271 | html_to_plaintext(blob_str(pIn), pOut); |
| 1272 | }else{ |
| 1273 | blob_append(pOut, "\n", 1); |
| 1274 | blob_append(pOut, blob_buffer(pIn), blob_size(pIn)); |
| 1275 | } |
| 1276 | blob_reset(&html); |
| 1277 | blob_reset(&title); |
| 1278 | } |
| @@ -1307,11 +1305,11 @@ | |
| 1305 | blob_appendf(pAccum, "%s: %s |\n", zColName, db_column_text(pQuery,i)); |
| 1306 | }else{ |
| 1307 | Blob txt; |
| 1308 | blob_init(&txt, db_column_text(pQuery,i), -1); |
| 1309 | blob_appendf(pAccum, "%s: ", zColName); |
| 1310 | get_stext_by_mimetype(&txt, zMime, pAccum); |
| 1311 | blob_append(pAccum, " |", 2); |
| 1312 | blob_reset(&txt); |
| 1313 | } |
| 1314 | } |
| 1315 | } |
| @@ -1346,11 +1344,11 @@ | |
| 1344 | switch( cType ){ |
| 1345 | case 'd': { /* Documents */ |
| 1346 | Blob doc; |
| 1347 | content_get(rid, &doc); |
| 1348 | blob_to_utf8_no_bom(&doc, 0); |
| 1349 | get_stext_by_mimetype(&doc, mimetype_from_name(zName), pOut); |
| 1350 | blob_reset(&doc); |
| 1351 | break; |
| 1352 | } |
| 1353 | case 'f': /* Forum messages */ |
| 1354 | case 'e': /* Tech Notes */ |
| @@ -1368,11 +1366,11 @@ | |
| 1366 | blob_appendf(&wiki, "From %s:\n\n%s", pWiki->zUser, pWiki->zWiki); |
| 1367 | }else{ |
| 1368 | blob_init(&wiki, pWiki->zWiki, -1); |
| 1369 | } |
| 1370 | get_stext_by_mimetype(&wiki, wiki_filter_mimetypes(pWiki->zMimetype), |
| 1371 | pOut); |
| 1372 | blob_reset(&wiki); |
| 1373 | manifest_destroy(pWiki); |
| 1374 | break; |
| 1375 | } |
| 1376 | case 'c': { /* Check-in Comments */ |
| @@ -1398,11 +1396,11 @@ | |
| 1396 | db_column_blob(&q, 0, pOut); |
| 1397 | }else{ |
| 1398 | Blob x; |
| 1399 | blob_init(&x,0,0); |
| 1400 | db_column_blob(&q, 0, &x); |
| 1401 | get_stext_by_mimetype(&x, "text/x-fossil-wiki", pOut); |
| 1402 | blob_reset(&x); |
| 1403 | } |
| 1404 | } |
| 1405 | db_reset(&q); |
| 1406 | break; |
| @@ -1509,11 +1507,11 @@ | |
| 1507 | Blob in, out; |
| 1508 | db_find_and_open_repository(0,0); |
| 1509 | if( g.argc!=4 ) usage("FILENAME MIMETYPE"); |
| 1510 | blob_read_from_file(&in, g.argv[2], ExtFILE); |
| 1511 | blob_init(&out, 0, 0); |
| 1512 | get_stext_by_mimetype(&in, g.argv[3], &out); |
| 1513 | fossil_print("%s\n",blob_str(&out)); |
| 1514 | blob_reset(&in); |
| 1515 | blob_reset(&out); |
| 1516 | } |
| 1517 | |
| 1518 |