203
204
205
206
207
208
209
210
211
212
213
214
215
216
|
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
|
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
|
** characters are encoded as "%HH" where HH is a two-digit hexidecimal
** representation of the character. The "/" character is not encoded
** by this routine.
*/
char *urlize(const char *z, int n){
return EncodeHttp(z, n, 0);
}
/*
** If input string does not contain quotes (niether ' nor ")
** then return the argument itself. Otherwise return a newly allocated
** copy of input with all quotes %-escaped.
*/
const char* escape_quotes(const char *zIn){
char *zRet, *zOut;
size_t i, n = 0;
for(i=0; zIn[i]; i++){
if( zIn[i]== '"' || zIn[i]== '\'' ) n++;
}
if( !n ) return zIn;
zRet = zOut = fossil_malloc( i + 2*n + 1 );
for(i=0; zIn[i]; i++){
if( zIn[i]=='"' ){
*(zOut++) = '%';
*(zOut++) = '2';
*(zOut++) = '2';
}else if( zIn[i]=='\'' ){
*(zOut++) = '%';
*(zOut++) = '2';
*(zOut++) = '7';
}else{
*(zOut++) = zIn[i];
}
}
*zOut = 0;
return zRet;
}
/*
** Convert a single HEX digit to an integer
*/
static int AsciiToHex(int c){
if( c>='a' && c<='f' ){
c += 10 - 'a';
|