Fossil SCM
Do not omit the [..] around hyperlinks in chat.
Commit
bd67c3cdf0f114a84db16fe169f5f13a25f23bc80d4207fb3a5fcd031179f635
Parent
7e2bc0848498728…
2 files changed
+4
-1
+10
-7
+4
-1
| --- src/chat.c | ||
| +++ src/chat.c | ||
| @@ -371,16 +371,19 @@ | ||
| 371 | 371 | zSafe[k] = 0; |
| 372 | 372 | if( j<i ){ |
| 373 | 373 | blob_append(&out, zSafe + j, i-j); |
| 374 | 374 | j = i; |
| 375 | 375 | } |
| 376 | - wiki_resolve_hyperlink(&out, WIKI_NOBADLINKS|WIKI_TARGET_BLANK, | |
| 376 | + blob_append_char(&out, '['); | |
| 377 | + wiki_resolve_hyperlink(&out, | |
| 378 | + WIKI_NOBADLINKS|WIKI_TARGET_BLANK|WIKI_NOBRACKET, | |
| 377 | 379 | zSafe+i+1, zClose, sizeof(zClose), zSafe, 0); |
| 378 | 380 | zSafe[k] = ']'; |
| 379 | 381 | j++; |
| 380 | 382 | blob_append(&out, zSafe + j, k - j); |
| 381 | 383 | blob_append(&out, zClose, -1); |
| 384 | + blob_append_char(&out, ']'); | |
| 382 | 385 | i = k; |
| 383 | 386 | j = k+1; |
| 384 | 387 | continue; |
| 385 | 388 | } |
| 386 | 389 | }else if( zSafe[i]=='h' |
| 387 | 390 |
| --- src/chat.c | |
| +++ src/chat.c | |
| @@ -371,16 +371,19 @@ | |
| 371 | zSafe[k] = 0; |
| 372 | if( j<i ){ |
| 373 | blob_append(&out, zSafe + j, i-j); |
| 374 | j = i; |
| 375 | } |
| 376 | wiki_resolve_hyperlink(&out, WIKI_NOBADLINKS|WIKI_TARGET_BLANK, |
| 377 | zSafe+i+1, zClose, sizeof(zClose), zSafe, 0); |
| 378 | zSafe[k] = ']'; |
| 379 | j++; |
| 380 | blob_append(&out, zSafe + j, k - j); |
| 381 | blob_append(&out, zClose, -1); |
| 382 | i = k; |
| 383 | j = k+1; |
| 384 | continue; |
| 385 | } |
| 386 | }else if( zSafe[i]=='h' |
| 387 |
| --- src/chat.c | |
| +++ src/chat.c | |
| @@ -371,16 +371,19 @@ | |
| 371 | zSafe[k] = 0; |
| 372 | if( j<i ){ |
| 373 | blob_append(&out, zSafe + j, i-j); |
| 374 | j = i; |
| 375 | } |
| 376 | blob_append_char(&out, '['); |
| 377 | wiki_resolve_hyperlink(&out, |
| 378 | WIKI_NOBADLINKS|WIKI_TARGET_BLANK|WIKI_NOBRACKET, |
| 379 | zSafe+i+1, zClose, sizeof(zClose), zSafe, 0); |
| 380 | zSafe[k] = ']'; |
| 381 | j++; |
| 382 | blob_append(&out, zSafe + j, k - j); |
| 383 | blob_append(&out, zClose, -1); |
| 384 | blob_append_char(&out, ']'); |
| 385 | i = k; |
| 386 | j = k+1; |
| 387 | continue; |
| 388 | } |
| 389 | }else if( zSafe[i]=='h' |
| 390 |
+10
-7
| --- src/wikiformat.c | ||
| +++ src/wikiformat.c | ||
| @@ -33,10 +33,11 @@ | ||
| 33 | 33 | #define WIKI_LINKSONLY 0x020 /* No markup. Only decorate links */ |
| 34 | 34 | #define WIKI_NEWLINE 0x040 /* Honor \n - break lines at each \n */ |
| 35 | 35 | #define WIKI_MARKDOWNLINKS 0x080 /* Resolve hyperlinks as in markdown */ |
| 36 | 36 | #define WIKI_SAFE 0x100 /* Make the result safe for embedding */ |
| 37 | 37 | #define WIKI_TARGET_BLANK 0x200 /* Hyperlinks go to a new window */ |
| 38 | +#define WIKI_NOBRACKET 0x400 /* Omit extra [..] around hyperlinks */ | |
| 38 | 39 | #endif |
| 39 | 40 | |
| 40 | 41 | |
| 41 | 42 | /* |
| 42 | 43 | ** These are the only markup attributes allowed. |
| @@ -1279,47 +1280,49 @@ | ||
| 1279 | 1280 | blob_appendf(pOut, "<a href=\"%h\"%s>", zTarget, zExtra); |
| 1280 | 1281 | }else if( zTarget[0]=='#' ){ |
| 1281 | 1282 | blob_appendf(pOut, "<a href=\"%h\"%s>", zTarget, zExtra); |
| 1282 | 1283 | }else if( is_valid_hname(zTarget) ){ |
| 1283 | 1284 | int isClosed = 0; |
| 1285 | + const char *zLB = (mFlags & WIKI_NOBRACKET)==0 ? "[" : ""; | |
| 1284 | 1286 | if( strlen(zTarget)<=HNAME_MAX && is_ticket(zTarget, &isClosed) ){ |
| 1285 | 1287 | /* Special display processing for tickets. Display the hyperlink |
| 1286 | 1288 | ** as crossed out if the ticket is closed. |
| 1287 | 1289 | */ |
| 1288 | 1290 | if( isClosed ){ |
| 1289 | 1291 | if( g.perm.Hyperlink ){ |
| 1290 | 1292 | blob_appendf(pOut, |
| 1291 | - "%z<span class=\"wikiTagCancelled\">[", | |
| 1292 | - xhref(zExtraNS,"%R/info/%s",zTarget) | |
| 1293 | + "%z<span class=\"wikiTagCancelled\">%s", | |
| 1294 | + xhref(zExtraNS,"%R/info/%s",zTarget), zLB | |
| 1293 | 1295 | ); |
| 1294 | 1296 | zTerm = "]</span></a>"; |
| 1295 | 1297 | }else{ |
| 1296 | - blob_appendf(pOut,"<span class=\"wikiTagCancelled\">["); | |
| 1298 | + blob_appendf(pOut,"<span class=\"wikiTagCancelled\">%s", zLB); | |
| 1297 | 1299 | zTerm = "]</span>"; |
| 1298 | 1300 | } |
| 1299 | 1301 | }else{ |
| 1300 | 1302 | if( g.perm.Hyperlink ){ |
| 1301 | - blob_appendf(pOut,"%z[", xhref(zExtraNS,"%R/info/%s", zTarget)); | |
| 1303 | + blob_appendf(pOut,"%z%s", xhref(zExtraNS,"%R/info/%s", zTarget),zLB); | |
| 1302 | 1304 | zTerm = "]</a>"; |
| 1303 | 1305 | }else{ |
| 1304 | - blob_appendf(pOut, "["); | |
| 1306 | + blob_appendf(pOut, "%s", zLB); | |
| 1305 | 1307 | zTerm = "]"; |
| 1306 | 1308 | } |
| 1307 | 1309 | } |
| 1308 | 1310 | }else if( !in_this_repo(zTarget) ){ |
| 1309 | 1311 | if( (mFlags & (WIKI_LINKSONLY|WIKI_NOBADLINKS))!=0 ){ |
| 1310 | 1312 | zTerm = ""; |
| 1311 | 1313 | }else{ |
| 1312 | - blob_appendf(pOut, "<span class=\"brokenlink\">["); | |
| 1314 | + blob_appendf(pOut, "<span class=\"brokenlink\">%s", zLB); | |
| 1313 | 1315 | zTerm = "]</span>"; |
| 1314 | 1316 | } |
| 1315 | 1317 | }else if( g.perm.Hyperlink ){ |
| 1316 | - blob_appendf(pOut, "%z[",xhref(zExtraNS, "%R/info/%s", zTarget)); | |
| 1318 | + blob_appendf(pOut, "%z%s",xhref(zExtraNS, "%R/info/%s", zTarget), zLB); | |
| 1317 | 1319 | zTerm = "]</a>"; |
| 1318 | 1320 | }else{ |
| 1319 | 1321 | zTerm = ""; |
| 1320 | 1322 | } |
| 1323 | + if( zTerm[0]==']' && (mFlags & WIKI_NOBRACKET)!=0 ) zTerm++; | |
| 1321 | 1324 | }else if( (zRemote = interwiki_url(zTarget))!=0 ){ |
| 1322 | 1325 | blob_appendf(pOut, "<a href=\"%z\"%s>", zRemote, zExtra); |
| 1323 | 1326 | zTerm = "</a>"; |
| 1324 | 1327 | }else if( (z = validWikiPageName(mFlags, zTarget))!=0 ){ |
| 1325 | 1328 | /* The link is to a valid wiki page name */ |
| 1326 | 1329 |
| --- src/wikiformat.c | |
| +++ src/wikiformat.c | |
| @@ -33,10 +33,11 @@ | |
| 33 | #define WIKI_LINKSONLY 0x020 /* No markup. Only decorate links */ |
| 34 | #define WIKI_NEWLINE 0x040 /* Honor \n - break lines at each \n */ |
| 35 | #define WIKI_MARKDOWNLINKS 0x080 /* Resolve hyperlinks as in markdown */ |
| 36 | #define WIKI_SAFE 0x100 /* Make the result safe for embedding */ |
| 37 | #define WIKI_TARGET_BLANK 0x200 /* Hyperlinks go to a new window */ |
| 38 | #endif |
| 39 | |
| 40 | |
| 41 | /* |
| 42 | ** These are the only markup attributes allowed. |
| @@ -1279,47 +1280,49 @@ | |
| 1279 | blob_appendf(pOut, "<a href=\"%h\"%s>", zTarget, zExtra); |
| 1280 | }else if( zTarget[0]=='#' ){ |
| 1281 | blob_appendf(pOut, "<a href=\"%h\"%s>", zTarget, zExtra); |
| 1282 | }else if( is_valid_hname(zTarget) ){ |
| 1283 | int isClosed = 0; |
| 1284 | if( strlen(zTarget)<=HNAME_MAX && is_ticket(zTarget, &isClosed) ){ |
| 1285 | /* Special display processing for tickets. Display the hyperlink |
| 1286 | ** as crossed out if the ticket is closed. |
| 1287 | */ |
| 1288 | if( isClosed ){ |
| 1289 | if( g.perm.Hyperlink ){ |
| 1290 | blob_appendf(pOut, |
| 1291 | "%z<span class=\"wikiTagCancelled\">[", |
| 1292 | xhref(zExtraNS,"%R/info/%s",zTarget) |
| 1293 | ); |
| 1294 | zTerm = "]</span></a>"; |
| 1295 | }else{ |
| 1296 | blob_appendf(pOut,"<span class=\"wikiTagCancelled\">["); |
| 1297 | zTerm = "]</span>"; |
| 1298 | } |
| 1299 | }else{ |
| 1300 | if( g.perm.Hyperlink ){ |
| 1301 | blob_appendf(pOut,"%z[", xhref(zExtraNS,"%R/info/%s", zTarget)); |
| 1302 | zTerm = "]</a>"; |
| 1303 | }else{ |
| 1304 | blob_appendf(pOut, "["); |
| 1305 | zTerm = "]"; |
| 1306 | } |
| 1307 | } |
| 1308 | }else if( !in_this_repo(zTarget) ){ |
| 1309 | if( (mFlags & (WIKI_LINKSONLY|WIKI_NOBADLINKS))!=0 ){ |
| 1310 | zTerm = ""; |
| 1311 | }else{ |
| 1312 | blob_appendf(pOut, "<span class=\"brokenlink\">["); |
| 1313 | zTerm = "]</span>"; |
| 1314 | } |
| 1315 | }else if( g.perm.Hyperlink ){ |
| 1316 | blob_appendf(pOut, "%z[",xhref(zExtraNS, "%R/info/%s", zTarget)); |
| 1317 | zTerm = "]</a>"; |
| 1318 | }else{ |
| 1319 | zTerm = ""; |
| 1320 | } |
| 1321 | }else if( (zRemote = interwiki_url(zTarget))!=0 ){ |
| 1322 | blob_appendf(pOut, "<a href=\"%z\"%s>", zRemote, zExtra); |
| 1323 | zTerm = "</a>"; |
| 1324 | }else if( (z = validWikiPageName(mFlags, zTarget))!=0 ){ |
| 1325 | /* The link is to a valid wiki page name */ |
| 1326 |
| --- src/wikiformat.c | |
| +++ src/wikiformat.c | |
| @@ -33,10 +33,11 @@ | |
| 33 | #define WIKI_LINKSONLY 0x020 /* No markup. Only decorate links */ |
| 34 | #define WIKI_NEWLINE 0x040 /* Honor \n - break lines at each \n */ |
| 35 | #define WIKI_MARKDOWNLINKS 0x080 /* Resolve hyperlinks as in markdown */ |
| 36 | #define WIKI_SAFE 0x100 /* Make the result safe for embedding */ |
| 37 | #define WIKI_TARGET_BLANK 0x200 /* Hyperlinks go to a new window */ |
| 38 | #define WIKI_NOBRACKET 0x400 /* Omit extra [..] around hyperlinks */ |
| 39 | #endif |
| 40 | |
| 41 | |
| 42 | /* |
| 43 | ** These are the only markup attributes allowed. |
| @@ -1279,47 +1280,49 @@ | |
| 1280 | blob_appendf(pOut, "<a href=\"%h\"%s>", zTarget, zExtra); |
| 1281 | }else if( zTarget[0]=='#' ){ |
| 1282 | blob_appendf(pOut, "<a href=\"%h\"%s>", zTarget, zExtra); |
| 1283 | }else if( is_valid_hname(zTarget) ){ |
| 1284 | int isClosed = 0; |
| 1285 | const char *zLB = (mFlags & WIKI_NOBRACKET)==0 ? "[" : ""; |
| 1286 | if( strlen(zTarget)<=HNAME_MAX && is_ticket(zTarget, &isClosed) ){ |
| 1287 | /* Special display processing for tickets. Display the hyperlink |
| 1288 | ** as crossed out if the ticket is closed. |
| 1289 | */ |
| 1290 | if( isClosed ){ |
| 1291 | if( g.perm.Hyperlink ){ |
| 1292 | blob_appendf(pOut, |
| 1293 | "%z<span class=\"wikiTagCancelled\">%s", |
| 1294 | xhref(zExtraNS,"%R/info/%s",zTarget), zLB |
| 1295 | ); |
| 1296 | zTerm = "]</span></a>"; |
| 1297 | }else{ |
| 1298 | blob_appendf(pOut,"<span class=\"wikiTagCancelled\">%s", zLB); |
| 1299 | zTerm = "]</span>"; |
| 1300 | } |
| 1301 | }else{ |
| 1302 | if( g.perm.Hyperlink ){ |
| 1303 | blob_appendf(pOut,"%z%s", xhref(zExtraNS,"%R/info/%s", zTarget),zLB); |
| 1304 | zTerm = "]</a>"; |
| 1305 | }else{ |
| 1306 | blob_appendf(pOut, "%s", zLB); |
| 1307 | zTerm = "]"; |
| 1308 | } |
| 1309 | } |
| 1310 | }else if( !in_this_repo(zTarget) ){ |
| 1311 | if( (mFlags & (WIKI_LINKSONLY|WIKI_NOBADLINKS))!=0 ){ |
| 1312 | zTerm = ""; |
| 1313 | }else{ |
| 1314 | blob_appendf(pOut, "<span class=\"brokenlink\">%s", zLB); |
| 1315 | zTerm = "]</span>"; |
| 1316 | } |
| 1317 | }else if( g.perm.Hyperlink ){ |
| 1318 | blob_appendf(pOut, "%z%s",xhref(zExtraNS, "%R/info/%s", zTarget), zLB); |
| 1319 | zTerm = "]</a>"; |
| 1320 | }else{ |
| 1321 | zTerm = ""; |
| 1322 | } |
| 1323 | if( zTerm[0]==']' && (mFlags & WIKI_NOBRACKET)!=0 ) zTerm++; |
| 1324 | }else if( (zRemote = interwiki_url(zTarget))!=0 ){ |
| 1325 | blob_appendf(pOut, "<a href=\"%z\"%s>", zRemote, zExtra); |
| 1326 | zTerm = "</a>"; |
| 1327 | }else if( (z = validWikiPageName(mFlags, zTarget))!=0 ){ |
| 1328 | /* The link is to a valid wiki page name */ |
| 1329 |