Fossil

Check-in [b48068de]
Login

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

Overview
Comment: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.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | forum-v2
Files: files | file ages | folders
SHA3-256: b48068ded31082893420da4407984a456fb1e02bb0f5afd486ad98d920e70188
User & Date: drh 2018-07-25 15:02:27
Context
2018-07-25
16:10
Add the website_assert() macro. Fixes to forum post editing. check-in: e67efdd7 user: drh tags: forum-v2
15:02
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. check-in: b48068de user: drh tags: forum-v2
13:48
Make forum posts visible to object_description(). Add new diagnostics visible to users with the new "D" capability. check-in: 2883fb80 user: drh tags: forum-v2
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/cgi.c.

1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
  while( fossil_isspace(zIn[0]) ) zIn++;
  zOut = fossil_strdup(zIn);
  for(i=j=0; (c = zOut[i])!=0; i++){
    if( c=='\r' && zOut[i+1]=='\n' ) continue;
    zOut[j++] = c;
  }
  zOut[j] = 0;
  while( i>0 && fossil_isspace(zOut[j-1]) ) zOut[--j] = 0;
  return zOut;
}

/*
** Return true if the CGI parameter zName exists and is not equal to 0,
** or "no" or "off".
*/







|







1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
  while( fossil_isspace(zIn[0]) ) zIn++;
  zOut = fossil_strdup(zIn);
  for(i=j=0; (c = zOut[i])!=0; i++){
    if( c=='\r' && zOut[i+1]=='\n' ) continue;
    zOut[j++] = c;
  }
  zOut[j] = 0;
  while( j>0 && fossil_isspace(zOut[j-1]) ) zOut[--j] = 0;
  return zOut;
}

/*
** Return true if the CGI parameter zName exists and is not equal to 0,
** or "no" or "off".
*/

Changes to src/forum.c.

22
23
24
25
26
27
28

29
30
31
32
33
34
35
36
...
203
204
205
206
207
208
209


210

211
212
213
214
215
216
217
...
270
271
272
273
274
275
276


277
278
279
280
281
282
283
...
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
...
369
370
371
372
373
374
375


376
377
378
379
380
381
#include "forum.h"

/*
** Render a forum post for display
*/
void forum_render(const char *zMimetype, const char *zContent){
  Blob x;

  blob_init(&x, zContent, -1);
  wiki_render_by_mimetype(&x, zMimetype);
  blob_reset(&x);
}

/*
** Display all posts in a forum thread in chronological order
*/
................................................................................
  }
  blob_appendf(&x, "U %F\n", zUser);
  blob_appendf(&x, "W %d\n%s\n", strlen(zContent), zContent);
  md5sum_blob(&x, &cksum);
  blob_appendf(&x, "Z %b\n", &cksum);
  blob_reset(&cksum);
  if( P("dryrun") ){


    @ <pre>%h(blob_str(&x))</pre><hr>

  }else{
    int nrid = wiki_put(&x, 0, forum_need_moderation());
    cgi_redirectf("%R/forumthread/%S", rid_to_uuid(nrid));
    return 1;
  }

forum_post_error:
................................................................................
  if( g.perm.Debug ){
    /* For the test-forumnew page add these extra debugging controls */
    @ <div class="debug">
    @ <label><input type="checkbox" name="dryrun" %s(PCK("dryrun"))> \
    @ Dry run</label>
    @ <br><label><input type="checkbox" name="domod" %s(PCK("domod"))> \
    @ Require moderator approval</label>


    @ </div>
  }
  @ </form>
  style_footer();
}

/*
................................................................................
      return;
    }
    if( P("reject") ){
      webpage_not_yet_implemented();
      return;
    }
  }
  if( P("submitdryrun") ){
    cgi_set_parameter_nocopy("dryrun","1",1);
    cgi_set_parameter_nocopy("submit","1",1);
  }
  if( P("submit") && cgi_csrf_safe(1) ){
    int done = 1;
    const char *zMimetype = PD("mimetype","text/x-fossil-wiki");
    const char *zContent = PDT("content","");
    if( P("reply") ){
      done = forum_post(0, fpid, 0, 0, zMimetype, zContent);
    }else if( P("edit") ){
................................................................................
    if( g.perm.Debug ){
      /* For the test-forumnew page add these extra debugging controls */
      @ <div class="debug">
      @ <label><input type="checkbox" name="dryrun" %s(PCK("dryrun"))> \
      @ Dry run</label>
      @ <br><label><input type="checkbox" name="domod" %s(PCK("domod"))> \
      @ Require moderator approval</label>


      @ </div>
    }
    @ </form>
  }
  style_footer();
}







>
|







 







>
>
|
>







 







>
>







 







<
<
<
<







 







>
>






22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
...
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
...
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
...
328
329
330
331
332
333
334




335
336
337
338
339
340
341
...
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
#include "forum.h"

/*
** Render a forum post for display
*/
void forum_render(const char *zMimetype, const char *zContent){
  Blob x;
  blob_init(&x, 0, 0);
  blob_append(&x, zContent, -1);
  wiki_render_by_mimetype(&x, zMimetype);
  blob_reset(&x);
}

/*
** Display all posts in a forum thread in chronological order
*/
................................................................................
  }
  blob_appendf(&x, "U %F\n", zUser);
  blob_appendf(&x, "W %d\n%s\n", strlen(zContent), zContent);
  md5sum_blob(&x, &cksum);
  blob_appendf(&x, "Z %b\n", &cksum);
  blob_reset(&cksum);
  if( P("dryrun") ){
    @ <div class='debug'>
    @ This is the artifact that would have been generated:
    @ <pre>%h(blob_str(&x))</pre>
    @ </div>
  }else{
    int nrid = wiki_put(&x, 0, forum_need_moderation());
    cgi_redirectf("%R/forumthread/%S", rid_to_uuid(nrid));
    return 1;
  }

forum_post_error:
................................................................................
  if( g.perm.Debug ){
    /* For the test-forumnew page add these extra debugging controls */
    @ <div class="debug">
    @ <label><input type="checkbox" name="dryrun" %s(PCK("dryrun"))> \
    @ Dry run</label>
    @ <br><label><input type="checkbox" name="domod" %s(PCK("domod"))> \
    @ Require moderator approval</label>
    @ <br><label><input type="checkbox" name="showqp" %s(PCK("showqp"))> \
    @ Show query parameters</label>
    @ </div>
  }
  @ </form>
  style_footer();
}

/*
................................................................................
      return;
    }
    if( P("reject") ){
      webpage_not_yet_implemented();
      return;
    }
  }




  if( P("submit") && cgi_csrf_safe(1) ){
    int done = 1;
    const char *zMimetype = PD("mimetype","text/x-fossil-wiki");
    const char *zContent = PDT("content","");
    if( P("reply") ){
      done = forum_post(0, fpid, 0, 0, zMimetype, zContent);
    }else if( P("edit") ){
................................................................................
    if( g.perm.Debug ){
      /* For the test-forumnew page add these extra debugging controls */
      @ <div class="debug">
      @ <label><input type="checkbox" name="dryrun" %s(PCK("dryrun"))> \
      @ Dry run</label>
      @ <br><label><input type="checkbox" name="domod" %s(PCK("domod"))> \
      @ Require moderator approval</label>
      @ <br><label><input type="checkbox" name="showqp" %s(PCK("showqp"))> \
      @ Show query parameters</label>
      @ </div>
    }
    @ </form>
  }
  style_footer();
}

Changes to src/style.c.

431
432
433
434
435
436
437





438
439
440
441
442
443
444
  Th_Render(zHeader);
  if( g.thTrace ) Th_Trace("END_HEADER<br />\n", -1);
  Th_Unstore("title");   /* Avoid collisions with ticket field names */
  cgi_destination(CGI_BODY);
  g.cgiOutput = 1;
  headerHasBeenGenerated = 1;
  sideboxUsed = 0;





}

#if INTERFACE
/* Allowed parameters for style_adunit() */
#define ADUNIT_OFF        0x0001       /* Do not allow ads on this page */
#define ADUNIT_RIGHT_OK   0x0002       /* Right-side vertical ads ok here */
#endif







>
>
>
>
>







431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
  Th_Render(zHeader);
  if( g.thTrace ) Th_Trace("END_HEADER<br />\n", -1);
  Th_Unstore("title");   /* Avoid collisions with ticket field names */
  cgi_destination(CGI_BODY);
  g.cgiOutput = 1;
  headerHasBeenGenerated = 1;
  sideboxUsed = 0;
  if( g.perm.Debug && P("showqp") ){
    @ <div class="debug">
    cgi_print_all(0, 0);
    @ </div>
  }
}

#if INTERFACE
/* Allowed parameters for style_adunit() */
#define ADUNIT_OFF        0x0001       /* Do not allow ads on this page */
#define ADUNIT_RIGHT_OK   0x0002       /* Right-side vertical ads ok here */
#endif