Fossil

Check-in [8f423ad438]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Fix a bug in wiki rendering that caused an extra paragraph end tag following a hyperlink.
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 8f423ad438265edb43a2e014e4901123bd0930bc
User & Date: drh 2007-10-21 11:11:02.000
Context
2007-10-23
16:30
Add a #include of <sys/types.h> to sha1.c. I am told this help it to compile on BSD systems. check-in: 17486c353f user: drh tags: trunk
2007-10-21
11:11
Fix a bug in wiki rendering that caused an extra paragraph end tag following a hyperlink. check-in: 8f423ad438 user: drh tags: trunk
2007-10-15
20:45
Fix the "add" command is that it does not allow users to accidently add files that contain shell wildcard characters. check-in: da9d38e2c3 user: drh tags: trunk
Changes
Unified Diff Ignore Whitespace Patch
Changes to src/tkt.c.
50
51
52
53
54
55
56









57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75



76
77
78
79


80
81


82
83
84

























































85
86
87
88
89
90
91
** Add the "tkt_" prefix to all of these names in the real table.
** The real table also contains some addition fields not found
** here.
*/
static int nField = 0;
static Blob fieldList;
static char **azField = 0;










/*
** Subscript command:      LIST setfields
**
** Parse up the list and populate the nField and azField variables.
*/
static int setFieldsCmd(struct Subscript *p, void *pNotUsed){
  if( SbS_RequireStack(p, 1) ) return 1;
  if( nField==0 ){
    char *zFieldList;
    int nFieldList, i;
    Blob field;
    blob_zero(&fieldList);
    zFieldList = SbS_StackValue(p, 0, &nFieldList);
    blob_appendf(&fieldList, zFieldList, nFieldList);
    while( blob_token(&fieldList, &field) ){
      nField++;
    }
    azField = malloc( sizeof(azField[0])*nField );



    blob_rewind(&fieldList);
    i = 0;
    while( blob_token(&fieldList, &field) ){
      azField[i] = blob_terminate(&field);


    }
  }


  SbS_Pop(p, 1);
  return 0;
}


























































/*
** Subscript command:      INTEGER not INTEGER
*/
static int notCmd(struct Subscript *p, void *pNotUsed){
  int n;
  if( SbS_RequireStack(p, 1) ) return 1;







>
>
>
>
>
>
>
>
>


















|
>
>
>
|
|
|
|
>
>
|
|
>
>



>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
** Add the "tkt_" prefix to all of these names in the real table.
** The real table also contains some addition fields not found
** here.
*/
static int nField = 0;
static Blob fieldList;
static char **azField = 0;
static char **azValue = 0;
static unsigned char *aChanged = 0;

/*
** Compare two entries in azField for sorting purposes
*/
static int nameCmpr(void *a, void *b){
  return strcmp((char*)a, (char*)b);
}

/*
** Subscript command:      LIST setfields
**
** Parse up the list and populate the nField and azField variables.
*/
static int setFieldsCmd(struct Subscript *p, void *pNotUsed){
  if( SbS_RequireStack(p, 1) ) return 1;
  if( nField==0 ){
    char *zFieldList;
    int nFieldList, i;
    Blob field;
    blob_zero(&fieldList);
    zFieldList = SbS_StackValue(p, 0, &nFieldList);
    blob_appendf(&fieldList, zFieldList, nFieldList);
    while( blob_token(&fieldList, &field) ){
      nField++;
    }
    azField = malloc( sizeof(azField[0])*nField*2 + nField );
    if( azField ){
      azValue = &azField[nField];
      aChanged = (unsigned char*)&azValue[nField];
      blob_rewind(&fieldList);
      i = 0;
      while( blob_token(&fieldList, &field) ){
        azField[i] = blob_terminate(&field);
        azValue[i] = 0;
        aChanged[i] = 0;
      }
    }
    qsort(azField, nField, sizeof(azField[0]), nameCmpr);
  }
  SbS_Pop(p, 1);
  return 0;
}

/*
** Find the text of the field whose name is the Nth element down
** on the Subscript stack.  0 means the top of the stack.
**
** First check for a value for this field as passed in via
** CGI parameter.  If not found, then use the value from the
** database.
*/
static const char *field_value(int N){
  const char *zFName;
  int nFName;
  char *zName;
  int i;
  const char *zValue;
  
  zFName = SbS_StackValue(pInterp, N, &nFName);
  if( zField==0 ){
    return 0;
  }
  zName = mprintf("%.*s", nFName, zFName);
  zValue = P(zName);
  if( zValue==0 ){
    for(i=0; i<nField; i++){
      if( strcmp(azField[i], zName)==0 ){
        zValue = azValue[i];
        break;
      }
    }
  }
  free(zName);
  return zValue;
}

/*
** Fill in the azValue[] array with the contents of the ticket
** table for the entry determined by the "name" CGI parameter.
*/
static void fetchOriginalValues(void){
  Blob sql;
  Stmt q;
  int i;
  char *zSep = "SELECT ";
  blob_zero(&sql);
  for(i=0; i<nField; i++){
    blob_appendf(&sql, "%s%s", zSep, azField[i]);
    zSep = ", ";
  }
  blob_appendf(" FROM ticket WHERE uuid=%Q", PD("name",""));
  db_prepare(&q, "%b", &sql);
  if( db_step(&q)==SQLITE_ROW ){
    for(i=0; i<nField; i++){
      azValue[i] = db_column_malloc(&q, i);
    }
  }
  db_finalize(&q);
}

/*
** Subscript command:      INTEGER not INTEGER
*/
static int notCmd(struct Subscript *p, void *pNotUsed){
  int n;
  if( SbS_RequireStack(p, 1) ) return 1;
Changes to src/wikiformat.c.
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
          renderMarkup(p->pOut, &markup);
        }
        break;
      }
    }
    z += n;
  }
  endAutoParagraph(p);
}


/*
** Transform the text in the pIn blob.  Write the results
** into the pOut blob.  The pOut blob should already be
** initialized.  The output is merely appended to pOut.







<







1005
1006
1007
1008
1009
1010
1011

1012
1013
1014
1015
1016
1017
1018
          renderMarkup(p->pOut, &markup);
        }
        break;
      }
    }
    z += n;
  }

}


/*
** Transform the text in the pIn blob.  Write the results
** into the pOut blob.  The pOut blob should already be
** initialized.  The output is merely appended to pOut.
1031
1032
1033
1034
1035
1036
1037

1038
1039
1040
1041
1042
1043
1044
    renderer.pOut = pOut;
  }else{
    renderer.pOut = cgi_output_blob();
  }

  z = blob_str(pIn);
  wiki_render(&renderer, z);

  while( renderer.nStack ){
    popStack(&renderer);
  }
  blob_append(renderer.pOut, "\n", 1);
  free(renderer.aStack);
}








>







1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
    renderer.pOut = pOut;
  }else{
    renderer.pOut = cgi_output_blob();
  }

  z = blob_str(pIn);
  wiki_render(&renderer, z);
  endAutoParagraph(&renderer);
  while( renderer.nStack ){
    popStack(&renderer);
  }
  blob_append(renderer.pOut, "\n", 1);
  free(renderer.aStack);
}