Fossil

Check-in [b982c001]
Login

Check-in [b982c001]

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

Overview
Comment:At /rptview page show link to /reportslist. If request's query string contains rvsmpl parameter then also show an auxiliary link to the page defined by the value of this parameter. Labels and links rendered via %s format specifier because %h and %T did not work properly. In this particular case this seems fine because style_finish_page() renders HTML via %h(...). Code review is very welcome though.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | rptview-submenu-paralink
Files: files | file ages | folders
SHA3-256: b982c00150e828b578c62880b5573985e0832b5f6089b65ca4a7ae938d1a91c7
User & Date: george 2021-03-25 04:11:31
Original Comment: At /rptview page show link to /reportslist. If request's query string contains [<b>rvsmpl</b>] parameter then also show an auxiliary link to the page defined by the value of this parameter. Labels and links rendered via %s format specifier because %h and %T did not work properly. In this particular case this seems fine because the values are rendered via %href(). Code review is very welcome though.
References
2021-03-31
22:53
Fix (URL-decode) a hyperlink that gets into clipboard when user selects a line of code (or a range of lines) and clicks "copy-to-clipboard". This affects /file, /artifact and /whatis pages. This fix may be somewhat suboptimal or incomplete: it may be worth investigating why some submenu's links are mangled on a server's side and fix it there (hint: perhaps %T and %h formatting does not play well with style_submenu_*() family of functions, see also check-in [b982c00150] and post b8ea664a57). ... (check-in: 89815187 user: george tags: trunk)
Context
2021-03-26
17:20
Allow a page's submenu to have multiple parametric hyperlinks induced by several different query string parameters. Use a common suffixes (smpl,smpl1,...smpl9) to probe for defined parameters. Relax constraints on hyperlink values to allow linking to wiki pages (for example). As a proof of concept add support of paralinks to the /wiki page. Get rid of dangling '&' at the endings. ... (check-in: d075801a user: george tags: rptview-submenu-paralink)
2021-03-25
04:11
At /rptview page show link to /reportslist. If request's query string contains rvsmpl parameter then also show an auxiliary link to the page defined by the value of this parameter. Labels and links rendered via %s format specifier because %h and %T did not work properly. In this particular case this seems fine because style_finish_page() renders HTML via %h(...). Code review is very welcome though. ... (check-in: b982c001 user: george tags: rptview-submenu-paralink)
2021-03-24
15:40
Update the form spider protections so that links to /register go through even if spider protection is fully enabled. This allows self-registration even if user "nobody" has no permissions. ... (check-in: 89b724dc user: drh tags: trunk)
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/report.c.

966
967
968
969
970
971
972
973
974
975
976





977
978
979
980
981
982
983
984
985
986
987
988

989
990
991
992
993
994
995
  fossil_free((void *)azVals);
  return rc;
}

/*
** WEBPAGE: rptview
**
** Generate a report.  The rn query parameter is the report number
** corresponding to REPORTFMT.RN.  If the tablist query parameter exists,
** then the output consists of lines of tab-separated fields instead of
** an HTML table.





*/
void rptview_page(void){
  int count = 0;
  int rn, rc;
  char *zSql;
  char *zTitle;
  char *zOwner;
  char *zClrKey;
  int tabs;
  Stmt q;
  char *zErr1 = 0;
  char *zErr2 = 0;


  login_check_credentials();
  if( !g.perm.RdTkt ){ login_needed(g.anon.RdTkt); return; }
  tabs = P("tablist")!=0;
  db_prepare(&q,
    "SELECT title, sqlcode, owner, cols, rn FROM reportfmt WHERE rn=%d",
     atoi(PD("rn","0")));







|
|

|
>
>
>
>
>












>







966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
  fossil_free((void *)azVals);
  return rc;
}

/*
** WEBPAGE: rptview
**
** Generate a report.  The "rn" query parameter is the report number
** corresponding to REPORTFMT.RN.  If the "tablist" query parameter exists,
** then the output consists of lines of tab-separated fields instead of
** an HTML table.  If the "rvsmpl" query parameter is set to an ordinary
** unfuncy ASCII string (alphanumerics, '_' and '-') then report's
** submenu will contain an extra hyperlink that have a value-driven
** label and target.
**
** "rvsmpl" stands for Report View SubMenu's Parametric Link.
*/
void rptview_page(void){
  int count = 0;
  int rn, rc;
  char *zSql;
  char *zTitle;
  char *zOwner;
  char *zClrKey;
  int tabs;
  Stmt q;
  char *zErr1 = 0;
  char *zErr2 = 0;
  const char *zQS;   /* QUERY_STRING  */

  login_check_credentials();
  if( !g.perm.RdTkt ){ login_needed(g.anon.RdTkt); return; }
  tabs = P("tablist")!=0;
  db_prepare(&q,
    "SELECT title, sqlcode, owner, cols, rn FROM reportfmt WHERE rn=%d",
     atoi(PD("rn","0")));
1030
1031
1032
1033
1034
1035
1036

1037



1038
1039
1040
1041
1042
1043
1044

  count = 0;
  if( !tabs ){
    struct GenerateHTML sState = { 0, 0, 0, 0, 0, 0, 0, 0, 0 };

    db_multi_exec("PRAGMA empty_result_callbacks=ON");
    style_set_current_feature("report");

    style_submenu_element("Raw", "rptview?tablist=1&rn=%d&%h", rn, PD("QUERY_STRING","") );



    if( g.perm.Admin
       || (g.perm.TktFmt && g.zLogin && fossil_strcmp(g.zLogin,zOwner)==0) ){
      style_submenu_element("Edit", "rptedit?rn=%d", rn);
    }
    if( g.perm.TktFmt ){
      style_submenu_element("SQL", "rptsql?rn=%d",rn);
    }







>
|
>
>
>







1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054

  count = 0;
  if( !tabs ){
    struct GenerateHTML sState = { 0, 0, 0, 0, 0, 0, 0, 0, 0 };

    db_multi_exec("PRAGMA empty_result_callbacks=ON");
    style_set_current_feature("report");
    zQS = PD("QUERY_STRING","");
    style_submenu_element("Raw","%R/%s?tablist=1&%s",g.zPath,zQS);
    style_submenu_element("Reports","%R/reportlist?&%s",zQS);
    style_submenu_parametric("rvsmpl");

    if( g.perm.Admin
       || (g.perm.TktFmt && g.zLogin && fossil_strcmp(g.zLogin,zOwner)==0) ){
      style_submenu_element("Edit", "rptedit?rn=%d", rn);
    }
    if( g.perm.TktFmt ){
      style_submenu_element("SQL", "rptsql?rn=%d",rn);
    }

Changes to src/style.c.

327
328
329
330
331
332
333




















334
335
336
337
338
339
340
    aSubmenuCtrl[nSubmenuCtrl].iSize = n/2;
    aSubmenuCtrl[nSubmenuCtrl].azChoice = (const char *const *)az;
    aSubmenuCtrl[nSubmenuCtrl].eVisible = STYLE_NORMAL;
    aSubmenuCtrl[nSubmenuCtrl].eType = FF_MULTI;
    nSubmenuCtrl++;
  }
}





















/*
** Disable or enable the submenu
*/
void style_submenu_enable(int onOff){
  submenuEnable = onOff;
}







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







327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
    aSubmenuCtrl[nSubmenuCtrl].iSize = n/2;
    aSubmenuCtrl[nSubmenuCtrl].azChoice = (const char *const *)az;
    aSubmenuCtrl[nSubmenuCtrl].eVisible = STYLE_NORMAL;
    aSubmenuCtrl[nSubmenuCtrl].eType = FF_MULTI;
    nSubmenuCtrl++;
  }
}

/*  Add submenu hyperlink based on the value of arbitrary parameter
 *  in the request's query string.
 */
void style_submenu_parametric(
  const char *zName      /*  Query parameter name */
){
  const char *zV;   /* value of the corresponding parameter   */
  if( zName == 0 || zName[0] == 0 || !fossil_islower(zName[0]) ||
     !fossil_no_strange_characters(zName)) {
    return;
  }
  zV = PD(zName,"");
  if( zV[0] && fossil_no_strange_characters( zV )){
    assert( nSubmenu < count(aSubmenu) );
    aSubmenu[nSubmenu].zLabel = mprintf("[ %s ]",zV);  /* memory leak? */
    aSubmenu[nSubmenu].zLink  = mprintf("%R/%s?%s",zV,PD("QUERY_STRING",""));
    nSubmenu++;
  }
}

/*
** Disable or enable the submenu
*/
void style_submenu_enable(int onOff){
  submenuEnable = onOff;
}