Fossil SCM

Do not omit the [..] around hyperlinks in chat.

drh 2021-02-13 14:05 trunk
Commit bd67c3cdf0f114a84db16fe169f5f13a25f23bc80d4207fb3a5fcd031179f635
2 files changed +4 -1 +10 -7
+4 -1
--- src/chat.c
+++ src/chat.c
@@ -371,16 +371,19 @@
371371
zSafe[k] = 0;
372372
if( j<i ){
373373
blob_append(&out, zSafe + j, i-j);
374374
j = i;
375375
}
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,
377379
zSafe+i+1, zClose, sizeof(zClose), zSafe, 0);
378380
zSafe[k] = ']';
379381
j++;
380382
blob_append(&out, zSafe + j, k - j);
381383
blob_append(&out, zClose, -1);
384
+ blob_append_char(&out, ']');
382385
i = k;
383386
j = k+1;
384387
continue;
385388
}
386389
}else if( zSafe[i]=='h'
387390
--- 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 @@
3333
#define WIKI_LINKSONLY 0x020 /* No markup. Only decorate links */
3434
#define WIKI_NEWLINE 0x040 /* Honor \n - break lines at each \n */
3535
#define WIKI_MARKDOWNLINKS 0x080 /* Resolve hyperlinks as in markdown */
3636
#define WIKI_SAFE 0x100 /* Make the result safe for embedding */
3737
#define WIKI_TARGET_BLANK 0x200 /* Hyperlinks go to a new window */
38
+#define WIKI_NOBRACKET 0x400 /* Omit extra [..] around hyperlinks */
3839
#endif
3940
4041
4142
/*
4243
** These are the only markup attributes allowed.
@@ -1279,47 +1280,49 @@
12791280
blob_appendf(pOut, "<a href=\"%h\"%s>", zTarget, zExtra);
12801281
}else if( zTarget[0]=='#' ){
12811282
blob_appendf(pOut, "<a href=\"%h\"%s>", zTarget, zExtra);
12821283
}else if( is_valid_hname(zTarget) ){
12831284
int isClosed = 0;
1285
+ const char *zLB = (mFlags & WIKI_NOBRACKET)==0 ? "[" : "";
12841286
if( strlen(zTarget)<=HNAME_MAX && is_ticket(zTarget, &isClosed) ){
12851287
/* Special display processing for tickets. Display the hyperlink
12861288
** as crossed out if the ticket is closed.
12871289
*/
12881290
if( isClosed ){
12891291
if( g.perm.Hyperlink ){
12901292
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
12931295
);
12941296
zTerm = "]</span></a>";
12951297
}else{
1296
- blob_appendf(pOut,"<span class=\"wikiTagCancelled\">[");
1298
+ blob_appendf(pOut,"<span class=\"wikiTagCancelled\">%s", zLB);
12971299
zTerm = "]</span>";
12981300
}
12991301
}else{
13001302
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);
13021304
zTerm = "]</a>";
13031305
}else{
1304
- blob_appendf(pOut, "[");
1306
+ blob_appendf(pOut, "%s", zLB);
13051307
zTerm = "]";
13061308
}
13071309
}
13081310
}else if( !in_this_repo(zTarget) ){
13091311
if( (mFlags & (WIKI_LINKSONLY|WIKI_NOBADLINKS))!=0 ){
13101312
zTerm = "";
13111313
}else{
1312
- blob_appendf(pOut, "<span class=\"brokenlink\">[");
1314
+ blob_appendf(pOut, "<span class=\"brokenlink\">%s", zLB);
13131315
zTerm = "]</span>";
13141316
}
13151317
}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);
13171319
zTerm = "]</a>";
13181320
}else{
13191321
zTerm = "";
13201322
}
1323
+ if( zTerm[0]==']' && (mFlags & WIKI_NOBRACKET)!=0 ) zTerm++;
13211324
}else if( (zRemote = interwiki_url(zTarget))!=0 ){
13221325
blob_appendf(pOut, "<a href=\"%z\"%s>", zRemote, zExtra);
13231326
zTerm = "</a>";
13241327
}else if( (z = validWikiPageName(mFlags, zTarget))!=0 ){
13251328
/* The link is to a valid wiki page name */
13261329
--- 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

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button