Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
| Comment: | Make no transformation to wiki hyperlinks (text inside [..]) if the content is not a valid hyperlink. Formerly, the faulty hyperlink would be displayed within <span class="brokenlink">..<span>. |
|---|---|
| Downloads: | Tarball | ZIP archive |
| Timelines: | family | ancestors | descendants | both | trunk |
| Files: | files | file ages | folders |
| SHA1: |
90676f48f09d191360b560cb2baae6fb |
| User & Date: | drh 2012-11-19 13:54:55.570 |
Context
|
2012-11-19
| ||
| 16:41 | Fix the git-fast-export generator so that it does not make links to files that for some reason or another do not exist in the repository. Also fix some stylistic problems in the export code. ... (check-in: c3bfb0083a user: drh tags: trunk) | |
| 13:54 | Make no transformation to wiki hyperlinks (text inside [..]) if the content is not a valid hyperlink. Formerly, the faulty hyperlink would be displayed within <span class="brokenlink">..<span>. ... (check-in: 90676f48f0 user: drh tags: trunk) | |
|
2012-11-17
| ||
| 19:16 | Fix the server-side sync operation so that it will not generate a delta loop when a file changes from its original state through two or more intermediate states and back to its original state and all versions of the file attempt to sync in a single transaction. ... (check-in: e5b8eb1235 user: drh tags: trunk) | |
Changes
Changes to src/wikiformat.c.
| ︙ | ︙ | |||
26 27 28 29 30 31 32 33 34 35 36 37 38 39 | ** Allowed wiki transformation operations */ #define WIKI_NOFOLLOW 0x001 #define WIKI_HTML 0x002 #define WIKI_INLINE 0x004 /* Do not surround with <p>..</p> */ #define WIKI_NOBLOCK 0x008 /* No block markup of any kind */ #define WIKI_BUTTONS 0x010 /* Allow sub-menu buttons */ #endif /* ** These are the only markup attributes allowed. */ #define ATTR_ALIGN 1 | > > | 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 | ** Allowed wiki transformation operations */ #define WIKI_NOFOLLOW 0x001 #define WIKI_HTML 0x002 #define WIKI_INLINE 0x004 /* Do not surround with <p>..</p> */ #define WIKI_NOBLOCK 0x008 /* No block markup of any kind */ #define WIKI_BUTTONS 0x010 /* Allow sub-menu buttons */ #define WIKI_NOBADLINKS 0x020 /* Ignore broken hyperlinks */ #define WIKI_DECORATEONLY 0x040 /* No markup. Only decorate links */ #endif /* ** These are the only markup attributes allowed. */ #define ATTR_ALIGN 1 |
| ︙ | ︙ | |||
394 395 396 397 398 399 400 401 402 403 404 405 406 407 |
/*
** Current state of the rendering engine
*/
typedef struct Renderer Renderer;
struct Renderer {
Blob *pOut; /* Output appended to this blob */
int state; /* Flag that govern rendering */
int wikiList; /* Current wiki list type */
int inVerbatim; /* True in <verbatim> mode */
int preVerbState; /* Value of state prior to verbatim */
int wantAutoParagraph; /* True if a <p> is desired */
int inAutoParagraph; /* True if within an automatic paragraph */
const char *zVerbatimId; /* The id= attribute of <verbatim> */
int nStack; /* Number of elements on the stack */
| > | 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 |
/*
** Current state of the rendering engine
*/
typedef struct Renderer Renderer;
struct Renderer {
Blob *pOut; /* Output appended to this blob */
int state; /* Flag that govern rendering */
unsigned renderFlags; /* Flags from the client */
int wikiList; /* Current wiki list type */
int inVerbatim; /* True in <verbatim> mode */
int preVerbState; /* Value of state prior to verbatim */
int wantAutoParagraph; /* True if a <p> is desired */
int inAutoParagraph; /* True if within an automatic paragraph */
const char *zVerbatimId; /* The id= attribute of <verbatim> */
int nStack; /* Number of elements on the stack */
|
| ︙ | ︙ | |||
1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 |
*pClosed = db_column_int(&q, 0);
}else{
rc = 0;
}
db_reset(&q);
return rc;
}
/*
** Resolve a hyperlink. The zTarget argument is the content of the [...]
** in the wiki. Append to the output string whatever text is appropriate
** for opening the hyperlink. Write into zClose[0...nClose-1] text that will
** close the markup.
**
** Actually, this routine might or might not append the hyperlink, depending
** on current rendering rules: specifically does the current user have
** "History" permission.
**
** [http://www.fossil-scm.org/]
** [https://www.fossil-scm.org/]
| > > > > > > > > > > > > > > > > > > > > > | 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 |
*pClosed = db_column_int(&q, 0);
}else{
rc = 0;
}
db_reset(&q);
return rc;
}
/*
** Return a pointer to the name part of zTarget (skipping the "wiki:" prefix
** if there is one) if zTarget is a valid wiki page name. Return NULL if
** zTarget names a page that does not exist.
*/
static const char *validWikiPageName(const char *zTarget){
if( strncmp(zTarget, "wiki:", 5)==0
&& wiki_name_is_wellformed((const unsigned char*)zTarget) ){
return zTarget+5;
}
if( strcmp(zTarget, "Sandbox")==0 ) return zTarget;
if( wiki_name_is_wellformed((const unsigned char *)zTarget)
&& db_exists("SELECT 1 FROM tag WHERE tagname GLOB 'wiki-%q'", zTarget) ){
return zTarget;
}
return 0;
}
/*
** Resolve a hyperlink. The zTarget argument is the content of the [...]
** in the wiki. Append to the output string whatever text is appropriate
** for opening the hyperlink. Write into zClose[0...nClose-1] text that will
** close the markup.
**
** If this routine determines that no hyperlink should be generated, then
** set zClose[0] to 0.
**
** Actually, this routine might or might not append the hyperlink, depending
** on current rendering rules: specifically does the current user have
** "History" permission.
**
** [http://www.fossil-scm.org/]
** [https://www.fossil-scm.org/]
|
| ︙ | ︙ | |||
1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 |
const char *zTarget, /* Hyperlink target; text within [...] */
char *zClose, /* Write hyperlink closing text here */
int nClose, /* Bytes available in zClose[] */
const char *zOrig /* Complete document text */
){
const char *zTerm = "</a>";
assert( nClose>=20 );
if( strncmp(zTarget, "http:", 5)==0
|| strncmp(zTarget, "https:", 6)==0
|| strncmp(zTarget, "ftp:", 4)==0
|| strncmp(zTarget, "mailto:", 7)==0
){
blob_appendf(p->pOut, "<a href=\"%s\">", zTarget);
| > | 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 |
const char *zTarget, /* Hyperlink target; text within [...] */
char *zClose, /* Write hyperlink closing text here */
int nClose, /* Bytes available in zClose[] */
const char *zOrig /* Complete document text */
){
const char *zTerm = "</a>";
assert( nClose>=20 );
const char *z;
if( strncmp(zTarget, "http:", 5)==0
|| strncmp(zTarget, "https:", 6)==0
|| strncmp(zTarget, "ftp:", 4)==0
|| strncmp(zTarget, "mailto:", 7)==0
){
blob_appendf(p->pOut, "<a href=\"%s\">", zTarget);
|
| ︙ | ︙ | |||
1154 1155 1156 1157 1158 1159 1160 |
zTerm = "]</a>";
}else{
blob_appendf(p->pOut, "[");
zTerm = "]";
}
}
}else if( !in_this_repo(zTarget) ){
| > > > | | > < < | | < < | > | | | | 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 |
zTerm = "]</a>";
}else{
blob_appendf(p->pOut, "[");
zTerm = "]";
}
}
}else if( !in_this_repo(zTarget) ){
if( (p->state & (WIKI_DECORATEONLY|WIKI_NOBADLINKS))!=0 ){
zTerm = "";
}else{
blob_appendf(p->pOut, "<span class=\"brokenlink\">[", zTarget);
zTerm = "]</span>";
}
}else if( g.perm.Hyperlink ){
blob_appendf(p->pOut, "%z[",href("%R/info/%s", zTarget));
zTerm = "]</a>";
}
}else if( strlen(zTarget)>=10 && fossil_isdigit(zTarget[0]) && zTarget[4]=='-'
&& db_int(0, "SELECT datetime(%Q) NOT NULL", zTarget) ){
blob_appendf(p->pOut, "<a href=\"%R/timeline?c=%T\">", zTarget);
}else if( (z = validWikiPageName(zTarget))!=0 ){
blob_appendf(p->pOut, "<a href=\"%R/wiki?name=%T\">", z);
}else if( zTarget>=&zOrig[2] && !fossil_isspace(zTarget[-2]) ){
/* Probably an array subscript in code */
zTerm = "";
}else if( (p->state & (WIKI_NOBADLINKS|WIKI_DECORATEONLY))!=0 ){
zTerm = "";
}else{
blob_appendf(p->pOut, "<span class=\"brokenlink\">[%h]", zTarget);
zTerm = "</span>";
}
assert( strlen(zTerm)<nClose );
sqlite3_snprintf(nClose, zClose, "%s", zTerm);
}
/*
** Check to see if the given parsed markup is the correct
|
| ︙ | ︙ | |||
1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 |
}
case TOKEN_LINK: {
char *zTarget;
char *zDisplay = 0;
int i, j;
int savedState;
char zClose[20];
startAutoParagraph(p);
zTarget = &z[1];
for(i=1; z[i] && z[i]!=']'; i++){
if( z[i]=='|' && zDisplay==0 ){
zDisplay = &z[i+1];
z[i] = 0;
for(j=i-1; j>0 && fossil_isspace(z[j]); j--){ z[j] = 0; }
}
}
z[i] = 0;
if( zDisplay==0 ){
zDisplay = zTarget;
}else{
while( fossil_isspace(*zDisplay) ) zDisplay++;
}
openHyperlink(p, zTarget, zClose, sizeof(zClose), zOrig);
| > > > > > | | | | | | > > > > | 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 |
}
case TOKEN_LINK: {
char *zTarget;
char *zDisplay = 0;
int i, j;
int savedState;
char zClose[20];
char cS1 = 0;
int iS1;
startAutoParagraph(p);
zTarget = &z[1];
for(i=1; z[i] && z[i]!=']'; i++){
if( z[i]=='|' && zDisplay==0 ){
zDisplay = &z[i+1];
iS1 = i;
cS1 = z[i];
z[i] = 0;
for(j=i-1; j>0 && fossil_isspace(z[j]); j--){ z[j] = 0; }
}
}
z[i] = 0;
if( zDisplay==0 ){
zDisplay = zTarget;
}else{
while( fossil_isspace(*zDisplay) ) zDisplay++;
}
openHyperlink(p, zTarget, zClose, sizeof(zClose), zOrig);
if( zClose[0] ){
savedState = p->state;
p->state &= ~ALLOW_WIKI;
p->state |= FONT_MARKUP_ONLY;
wiki_render(p, zDisplay);
p->state = savedState;
blob_append(p->pOut, zClose, -1);
}else{
if( cS1 ) z[iS1] = cS1;
blob_appendf(p->pOut, "[%h]", zTarget);
}
break;
}
case TOKEN_TEXT: {
int i;
for(i=0; i<n && fossil_isspace(z[i]); i++){}
if( i<n ) startAutoParagraph(p);
blob_append(p->pOut, z, n);
|
| ︙ | ︙ | |||
1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 |
** into the pOut blob. The pOut blob should already be
** initialized. The output is merely appended to pOut.
** If pOut is NULL, then the output is appended to the CGI
** reply.
*/
void wiki_convert(Blob *pIn, Blob *pOut, int flags){
Renderer renderer;
memset(&renderer, 0, sizeof(renderer));
renderer.state = ALLOW_WIKI|AT_NEWLINE|AT_PARAGRAPH|flags;
if( flags & WIKI_NOBLOCK ){
renderer.state |= INLINE_MARKUP_ONLY;
}
if( flags & WIKI_INLINE ){
renderer.wantAutoParagraph = 0;
}else{
| > > > > | 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 |
** into the pOut blob. The pOut blob should already be
** initialized. The output is merely appended to pOut.
** If pOut is NULL, then the output is appended to the CGI
** reply.
*/
void wiki_convert(Blob *pIn, Blob *pOut, int flags){
Renderer renderer;
/* Never show bad hyperlinks */
flags |= WIKI_NOBADLINKS;
memset(&renderer, 0, sizeof(renderer));
renderer.renderFlags = flags;
renderer.state = ALLOW_WIKI|AT_NEWLINE|AT_PARAGRAPH|flags;
if( flags & WIKI_NOBLOCK ){
renderer.state |= INLINE_MARKUP_ONLY;
}
if( flags & WIKI_INLINE ){
renderer.wantAutoParagraph = 0;
}else{
|
| ︙ | ︙ |