Fossil SCM

If the user has the 'D' capability and the "showqp" query parameter exists, then all query parameters are shown at the top of the webpage. Also, fix some issues with forum.

drh 2018-07-25 15:02 forum-v2
Commit b48068ded31082893420da4407984a456fb1e02bb0f5afd486ad98d920e70188
3 files changed +1 -1 +10 -6 +5
+1 -1
--- src/cgi.c
+++ src/cgi.c
@@ -1128,11 +1128,11 @@
11281128
for(i=j=0; (c = zOut[i])!=0; i++){
11291129
if( c=='\r' && zOut[i+1]=='\n' ) continue;
11301130
zOut[j++] = c;
11311131
}
11321132
zOut[j] = 0;
1133
- while( i>0 && fossil_isspace(zOut[j-1]) ) zOut[--j] = 0;
1133
+ while( j>0 && fossil_isspace(zOut[j-1]) ) zOut[--j] = 0;
11341134
return zOut;
11351135
}
11361136
11371137
/*
11381138
** Return true if the CGI parameter zName exists and is not equal to 0,
11391139
--- src/cgi.c
+++ src/cgi.c
@@ -1128,11 +1128,11 @@
1128 for(i=j=0; (c = zOut[i])!=0; i++){
1129 if( c=='\r' && zOut[i+1]=='\n' ) continue;
1130 zOut[j++] = c;
1131 }
1132 zOut[j] = 0;
1133 while( i>0 && fossil_isspace(zOut[j-1]) ) zOut[--j] = 0;
1134 return zOut;
1135 }
1136
1137 /*
1138 ** Return true if the CGI parameter zName exists and is not equal to 0,
1139
--- src/cgi.c
+++ src/cgi.c
@@ -1128,11 +1128,11 @@
1128 for(i=j=0; (c = zOut[i])!=0; i++){
1129 if( c=='\r' && zOut[i+1]=='\n' ) continue;
1130 zOut[j++] = c;
1131 }
1132 zOut[j] = 0;
1133 while( j>0 && fossil_isspace(zOut[j-1]) ) zOut[--j] = 0;
1134 return zOut;
1135 }
1136
1137 /*
1138 ** Return true if the CGI parameter zName exists and is not equal to 0,
1139
+10 -6
--- src/forum.c
+++ src/forum.c
@@ -24,11 +24,12 @@
2424
/*
2525
** Render a forum post for display
2626
*/
2727
void forum_render(const char *zMimetype, const char *zContent){
2828
Blob x;
29
- blob_init(&x, zContent, -1);
29
+ blob_init(&x, 0, 0);
30
+ blob_append(&x, zContent, -1);
3031
wiki_render_by_mimetype(&x, zMimetype);
3132
blob_reset(&x);
3233
}
3334
3435
/*
@@ -205,11 +206,14 @@
205206
blob_appendf(&x, "W %d\n%s\n", strlen(zContent), zContent);
206207
md5sum_blob(&x, &cksum);
207208
blob_appendf(&x, "Z %b\n", &cksum);
208209
blob_reset(&cksum);
209210
if( P("dryrun") ){
210
- @ <pre>%h(blob_str(&x))</pre><hr>
211
+ @ <div class='debug'>
212
+ @ This is the artifact that would have been generated:
213
+ @ <pre>%h(blob_str(&x))</pre>
214
+ @ </div>
211215
}else{
212216
int nrid = wiki_put(&x, 0, forum_need_moderation());
213217
cgi_redirectf("%R/forumthread/%S", rid_to_uuid(nrid));
214218
return 1;
215219
}
@@ -272,10 +276,12 @@
272276
@ <div class="debug">
273277
@ <label><input type="checkbox" name="dryrun" %s(PCK("dryrun"))> \
274278
@ Dry run</label>
275279
@ <br><label><input type="checkbox" name="domod" %s(PCK("domod"))> \
276280
@ Require moderator approval</label>
281
+ @ <br><label><input type="checkbox" name="showqp" %s(PCK("showqp"))> \
282
+ @ Show query parameters</label>
277283
@ </div>
278284
}
279285
@ </form>
280286
style_footer();
281287
}
@@ -324,14 +330,10 @@
324330
if( P("reject") ){
325331
webpage_not_yet_implemented();
326332
return;
327333
}
328334
}
329
- if( P("submitdryrun") ){
330
- cgi_set_parameter_nocopy("dryrun","1",1);
331
- cgi_set_parameter_nocopy("submit","1",1);
332
- }
333335
if( P("submit") && cgi_csrf_safe(1) ){
334336
int done = 1;
335337
const char *zMimetype = PD("mimetype","text/x-fossil-wiki");
336338
const char *zContent = PDT("content","");
337339
if( P("reply") ){
@@ -371,11 +373,13 @@
371373
@ <div class="debug">
372374
@ <label><input type="checkbox" name="dryrun" %s(PCK("dryrun"))> \
373375
@ Dry run</label>
374376
@ <br><label><input type="checkbox" name="domod" %s(PCK("domod"))> \
375377
@ Require moderator approval</label>
378
+ @ <br><label><input type="checkbox" name="showqp" %s(PCK("showqp"))> \
379
+ @ Show query parameters</label>
376380
@ </div>
377381
}
378382
@ </form>
379383
}
380384
style_footer();
381385
}
382386
--- src/forum.c
+++ src/forum.c
@@ -24,11 +24,12 @@
24 /*
25 ** Render a forum post for display
26 */
27 void forum_render(const char *zMimetype, const char *zContent){
28 Blob x;
29 blob_init(&x, zContent, -1);
 
30 wiki_render_by_mimetype(&x, zMimetype);
31 blob_reset(&x);
32 }
33
34 /*
@@ -205,11 +206,14 @@
205 blob_appendf(&x, "W %d\n%s\n", strlen(zContent), zContent);
206 md5sum_blob(&x, &cksum);
207 blob_appendf(&x, "Z %b\n", &cksum);
208 blob_reset(&cksum);
209 if( P("dryrun") ){
210 @ <pre>%h(blob_str(&x))</pre><hr>
 
 
 
211 }else{
212 int nrid = wiki_put(&x, 0, forum_need_moderation());
213 cgi_redirectf("%R/forumthread/%S", rid_to_uuid(nrid));
214 return 1;
215 }
@@ -272,10 +276,12 @@
272 @ <div class="debug">
273 @ <label><input type="checkbox" name="dryrun" %s(PCK("dryrun"))> \
274 @ Dry run</label>
275 @ <br><label><input type="checkbox" name="domod" %s(PCK("domod"))> \
276 @ Require moderator approval</label>
 
 
277 @ </div>
278 }
279 @ </form>
280 style_footer();
281 }
@@ -324,14 +330,10 @@
324 if( P("reject") ){
325 webpage_not_yet_implemented();
326 return;
327 }
328 }
329 if( P("submitdryrun") ){
330 cgi_set_parameter_nocopy("dryrun","1",1);
331 cgi_set_parameter_nocopy("submit","1",1);
332 }
333 if( P("submit") && cgi_csrf_safe(1) ){
334 int done = 1;
335 const char *zMimetype = PD("mimetype","text/x-fossil-wiki");
336 const char *zContent = PDT("content","");
337 if( P("reply") ){
@@ -371,11 +373,13 @@
371 @ <div class="debug">
372 @ <label><input type="checkbox" name="dryrun" %s(PCK("dryrun"))> \
373 @ Dry run</label>
374 @ <br><label><input type="checkbox" name="domod" %s(PCK("domod"))> \
375 @ Require moderator approval</label>
 
 
376 @ </div>
377 }
378 @ </form>
379 }
380 style_footer();
381 }
382
--- src/forum.c
+++ src/forum.c
@@ -24,11 +24,12 @@
24 /*
25 ** Render a forum post for display
26 */
27 void forum_render(const char *zMimetype, const char *zContent){
28 Blob x;
29 blob_init(&x, 0, 0);
30 blob_append(&x, zContent, -1);
31 wiki_render_by_mimetype(&x, zMimetype);
32 blob_reset(&x);
33 }
34
35 /*
@@ -205,11 +206,14 @@
206 blob_appendf(&x, "W %d\n%s\n", strlen(zContent), zContent);
207 md5sum_blob(&x, &cksum);
208 blob_appendf(&x, "Z %b\n", &cksum);
209 blob_reset(&cksum);
210 if( P("dryrun") ){
211 @ <div class='debug'>
212 @ This is the artifact that would have been generated:
213 @ <pre>%h(blob_str(&x))</pre>
214 @ </div>
215 }else{
216 int nrid = wiki_put(&x, 0, forum_need_moderation());
217 cgi_redirectf("%R/forumthread/%S", rid_to_uuid(nrid));
218 return 1;
219 }
@@ -272,10 +276,12 @@
276 @ <div class="debug">
277 @ <label><input type="checkbox" name="dryrun" %s(PCK("dryrun"))> \
278 @ Dry run</label>
279 @ <br><label><input type="checkbox" name="domod" %s(PCK("domod"))> \
280 @ Require moderator approval</label>
281 @ <br><label><input type="checkbox" name="showqp" %s(PCK("showqp"))> \
282 @ Show query parameters</label>
283 @ </div>
284 }
285 @ </form>
286 style_footer();
287 }
@@ -324,14 +330,10 @@
330 if( P("reject") ){
331 webpage_not_yet_implemented();
332 return;
333 }
334 }
 
 
 
 
335 if( P("submit") && cgi_csrf_safe(1) ){
336 int done = 1;
337 const char *zMimetype = PD("mimetype","text/x-fossil-wiki");
338 const char *zContent = PDT("content","");
339 if( P("reply") ){
@@ -371,11 +373,13 @@
373 @ <div class="debug">
374 @ <label><input type="checkbox" name="dryrun" %s(PCK("dryrun"))> \
375 @ Dry run</label>
376 @ <br><label><input type="checkbox" name="domod" %s(PCK("domod"))> \
377 @ Require moderator approval</label>
378 @ <br><label><input type="checkbox" name="showqp" %s(PCK("showqp"))> \
379 @ Show query parameters</label>
380 @ </div>
381 }
382 @ </form>
383 }
384 style_footer();
385 }
386
--- src/style.c
+++ src/style.c
@@ -433,10 +433,15 @@
433433
Th_Unstore("title"); /* Avoid collisions with ticket field names */
434434
cgi_destination(CGI_BODY);
435435
g.cgiOutput = 1;
436436
headerHasBeenGenerated = 1;
437437
sideboxUsed = 0;
438
+ if( g.perm.Debug && P("showqp") ){
439
+ @ <div class="debug">
440
+ cgi_print_all(0, 0);
441
+ @ </div>
442
+ }
438443
}
439444
440445
#if INTERFACE
441446
/* Allowed parameters for style_adunit() */
442447
#define ADUNIT_OFF 0x0001 /* Do not allow ads on this page */
443448
--- src/style.c
+++ src/style.c
@@ -433,10 +433,15 @@
433 Th_Unstore("title"); /* Avoid collisions with ticket field names */
434 cgi_destination(CGI_BODY);
435 g.cgiOutput = 1;
436 headerHasBeenGenerated = 1;
437 sideboxUsed = 0;
 
 
 
 
 
438 }
439
440 #if INTERFACE
441 /* Allowed parameters for style_adunit() */
442 #define ADUNIT_OFF 0x0001 /* Do not allow ads on this page */
443
--- src/style.c
+++ src/style.c
@@ -433,10 +433,15 @@
433 Th_Unstore("title"); /* Avoid collisions with ticket field names */
434 cgi_destination(CGI_BODY);
435 g.cgiOutput = 1;
436 headerHasBeenGenerated = 1;
437 sideboxUsed = 0;
438 if( g.perm.Debug && P("showqp") ){
439 @ <div class="debug">
440 cgi_print_all(0, 0);
441 @ </div>
442 }
443 }
444
445 #if INTERFACE
446 /* Allowed parameters for style_adunit() */
447 #define ADUNIT_OFF 0x0001 /* Do not allow ads on this page */
448

Keyboard Shortcuts

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