Fossil

Check-in [1e1512f5]
Login

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

Overview
Comment:check for valid UUID on ticket set command
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | wolfgangTicketCmd
Files: files | file ages | folders
SHA1:1e1512f51053fa9a73bc7fb8fc83909fa4f963ea
User & Date: wolfgang 2010-10-05 15:44:32
Context
2010-10-05
16:37
fossil ticket show may use report name instead of report number check-in: 63d91f0b user: wolfgang tags: wolfgangTicketCmd
15:44
check for valid UUID on ticket set command check-in: 1e1512f5 user: wolfgang tags: wolfgangTicketCmd
13:46
implemented add/set ticket commands check-in: 9d3b9d65 user: wolfgang tags: wolfgangTicketCmd
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/tkt.c.

844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
...
861
862
863
864
865
866
867


868
869
870
871
872
873
874
...
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
...
913
914
915
916
917
918
919
920





921
922
923
924
925

926
927
928
929
930
931
932
...
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
**         Run the the ticket report, identified by the report number
**         used in the gui. The data is written as flat file on stdout,
**         using "," as separator. The seperator "," can be changed using
**         the -l or --limit option.
**         If TICKETFILTER is given on the commandline, the query is
**         limited with a new WHERE-condition.
**           example:  Report lists a column # with the uuid
**                     TICKETFILTER= [#]='uuuuuuuuu'
**
**     %fossil ticket set TICKETUUID FIELD VALUE ?FIELD VALUE ... ?
**
**         change ticket identified by TICKETUUID and set the value of
**         field FIELD to VALUE. Valid field descriptions are:
**            status, type, severity, priority, resolution,
**            foundin, private_contact, resolution, title or comment
................................................................................
**         change the all your configured columns.
**         You can use more than one field/value pair on the commandline.
**
**     %fossil ticket add FIELD VALUE ?FIELD VALUE ... ?
**
**         like set, but create a new ticket with the given values.
**


*/
void ticket_cmd(void){
  int n;

  db_must_be_within_tree();
  db_find_and_open_repository(1);

................................................................................
  user_select();
  /*
  ** Check that the user exists.
  */
  if( !db_exists("SELECT 1 FROM user WHERE login=%Q", g.zLogin) ){
    fossil_fatal("no such user: %s", g.zLogin);
  }
fprintf(stdout,"%s\n",g.zLogin);

  if( g.argc<3 ){
    usage("add|set|show");
  }else{
    n = strlen(g.argv[2]);
    if( n==1 && g.argv[2][0]=='s' ){
      usage("ticket show|set|add");
................................................................................

      /* get command type (set/add) and get uuid, if needed for set */
      if( strncmp(g.argv[2],"set",n)==0 ){
        eCmd = add;
        if( g.argc==3 ){
          fossil_fatal("set: missing TICKETUUID!");
        }
        zTktUuid = g.argv[3];





        i=4;
      }else if( strncmp(g.argv[2],"add",n)==0 ){
        eCmd = set;
        zTktUuid = 0;
        i = 3;

      }
      if( eCmd==err ){
        fossil_fatal("%s: unknown ticket command",g.argv[2]);
      }
      if( i==g.argc ){
        fossil_fatal("empty %s command aborted!",g.argv[2]);
      }
................................................................................
            zValue = db_conceal(zValue, strlen(zValue));
            blob_appendf(&tktchng, "J %s %s\n", azField[i], zValue);
          }else{
            blob_appendf(&tktchng, "J %s %#F\n", azField[i], strlen(zValue), zValue);
          }
        }
      }
      if( zTktUuid ){
        zTktUuid = db_text(0, 
          "SELECT tkt_uuid FROM ticket WHERE tkt_uuid GLOB '%s*'", zTktUuid
        );
      }else{
        zTktUuid = db_text(0, "SELECT lower(hex(randomblob(20)))");
      }
      blob_appendf(&tktchng, "K %s\n", zTktUuid);
      blob_appendf(&tktchng, "U %F\n", g.zLogin);
      md5sum_blob(&tktchng, &cksum);
      blob_appendf(&tktchng, "Z %b\n", &cksum);
      rid = content_put(&tktchng, 0, 0);
      if( rid==0 ){
        fossil_panic("trouble committing ticket: %s", g.zErrMsg);







|







 







>
>







 







<







 







|
>
>
>
>
>





>







 







<
<
<
<
<
<
<







844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
...
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
...
877
878
879
880
881
882
883

884
885
886
887
888
889
890
...
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
...
976
977
978
979
980
981
982







983
984
985
986
987
988
989
**         Run the the ticket report, identified by the report number
**         used in the gui. The data is written as flat file on stdout,
**         using "," as separator. The seperator "," can be changed using
**         the -l or --limit option.
**         If TICKETFILTER is given on the commandline, the query is
**         limited with a new WHERE-condition.
**           example:  Report lists a column # with the uuid
**                     TICKETFILTER may be [#]='uuuuuuuuu'
**
**     %fossil ticket set TICKETUUID FIELD VALUE ?FIELD VALUE ... ?
**
**         change ticket identified by TICKETUUID and set the value of
**         field FIELD to VALUE. Valid field descriptions are:
**            status, type, severity, priority, resolution,
**            foundin, private_contact, resolution, title or comment
................................................................................
**         change the all your configured columns.
**         You can use more than one field/value pair on the commandline.
**
**     %fossil ticket add FIELD VALUE ?FIELD VALUE ... ?
**
**         like set, but create a new ticket with the given values.
**
** The values in set|add are not validated against the definitions
** given in the "Ticket Common Script".
*/
void ticket_cmd(void){
  int n;

  db_must_be_within_tree();
  db_find_and_open_repository(1);

................................................................................
  user_select();
  /*
  ** Check that the user exists.
  */
  if( !db_exists("SELECT 1 FROM user WHERE login=%Q", g.zLogin) ){
    fossil_fatal("no such user: %s", g.zLogin);
  }


  if( g.argc<3 ){
    usage("add|set|show");
  }else{
    n = strlen(g.argv[2]);
    if( n==1 && g.argv[2][0]=='s' ){
      usage("ticket show|set|add");
................................................................................

      /* get command type (set/add) and get uuid, if needed for set */
      if( strncmp(g.argv[2],"set",n)==0 ){
        eCmd = add;
        if( g.argc==3 ){
          fossil_fatal("set: missing TICKETUUID!");
        }
        zTktUuid = db_text(0, 
          "SELECT tkt_uuid FROM ticket WHERE tkt_uuid GLOB '%s*'", g.argv[3]
        );
        if( !zTktUuid ){
          fossil_fatal("unknown ticket: '%s'!",g.argv[3]);
        }
        i=4;
      }else if( strncmp(g.argv[2],"add",n)==0 ){
        eCmd = set;
        zTktUuid = 0;
        i = 3;
        zTktUuid = db_text(0, "SELECT lower(hex(randomblob(20)))");
      }
      if( eCmd==err ){
        fossil_fatal("%s: unknown ticket command",g.argv[2]);
      }
      if( i==g.argc ){
        fossil_fatal("empty %s command aborted!",g.argv[2]);
      }
................................................................................
            zValue = db_conceal(zValue, strlen(zValue));
            blob_appendf(&tktchng, "J %s %s\n", azField[i], zValue);
          }else{
            blob_appendf(&tktchng, "J %s %#F\n", azField[i], strlen(zValue), zValue);
          }
        }
      }







      blob_appendf(&tktchng, "K %s\n", zTktUuid);
      blob_appendf(&tktchng, "U %F\n", g.zLogin);
      md5sum_blob(&tktchng, &cksum);
      blob_appendf(&tktchng, "Z %b\n", &cksum);
      rid = content_put(&tktchng, 0, 0);
      if( rid==0 ){
        fossil_panic("trouble committing ticket: %s", g.zErrMsg);