Ignore:
Timestamp:
10/01/10 20:37:20 (10 years ago)
Author:
ak19
Message:

Fix to bug causing depositor to crash library.cgi upon selecting a collection: code was previously looping on parameter names in args to substring them in order to compare them to a prefix. However, it also tried to substring them when the arg parameter name was shorter than the prefix. Fix was necessary in two locations (wizardaction and depositoraction).

Location:
main/trunk/greenstone2/runtime-src/src/recpt
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • main/trunk/greenstone2/runtime-src/src/recpt/depositoraction.cpp

    r22984 r23012  
    396396      text_t args_name = (*args_here).first;
    397397      int prefix_len = macro_prefix.size();
    398       text_t args_prefix = substr(args_name.begin(),args_name.begin()+prefix_len+3);
    399 
    400       if (args_prefix == (macro_prefix+"md.")) {     
    401     text_t args_val = args[args_name];
    402     text_t args_suffix = substr(args_name.begin()+prefix_len+3,args_name.end());
    403 
    404     text_tarray mdvalues;
    405     splitchar (args_val.begin(), args_val.end(), ',', mdvalues);
    406     int numvalues = mdvalues.size();
    407 
    408     for (int i = 0; i < numvalues; ++i) {
    409       if (!mdvalues[i].empty()) {         
    410         decode_cgi_arg(mdvalues[i]);
    411 
    412         if (cached_metadata_values == "") {
    413           cached_metadata_values = "var CachedMDValues = new Array(\\{";
    414         } else {
    415           cached_metadata_values += ",";
    416         }
    417 
    418         cached_metadata_values += "\"" + args_name + "\":\"" + args_val + "\"";
     398      int args_name_len = args_name.size();
     399
     400      if(args_name_len >= prefix_len+3) { // Only now can we substring args_name by prefix_len+3
     401          text_t args_prefix;
     402          if(args_name_len == prefix_len+3) {
     403              args_prefix = args_name;
     404          } else { // >, so substring
     405              args_prefix = substr(args_name.begin(),args_name.begin()+prefix_len+3);
     406          }
     407
     408          if (args_prefix == (macro_prefix+"md.")) {     
     409            text_t args_val = args[args_name];
     410            text_t args_suffix = substr(args_name.begin()+prefix_len+3,args_name.end());
     411
     412            text_tarray mdvalues;
     413            splitchar (args_val.begin(), args_val.end(), ',', mdvalues);
     414            int numvalues = mdvalues.size();
     415
     416            for (int i = 0; i < numvalues; ++i) {
     417              if (!mdvalues[i].empty()) {         
     418                decode_cgi_arg(mdvalues[i]);
     419
     420                if (cached_metadata_values == "") {
     421                  cached_metadata_values = "var CachedMDValues = new Array(\\{";
     422                } else {
     423                  cached_metadata_values += ",";
     424                }
     425
     426                cached_metadata_values += "\"" + args_name + "\":\"" + args_val + "\"";
     427              }
     428            }   
     429          }
    419430      }
    420     }   
    421       }
    422431      ++args_here;
    423432    }
  • main/trunk/greenstone2/runtime-src/src/recpt/wizardaction.cpp

    r22067 r23012  
    118118     
    119119      int prefix_len = macro_prefix.size();
    120      
    121       text_t args_prefix = substr(args_name.begin(),args_name.begin()+prefix_len);
    122      
    123       if (args_prefix == macro_prefix) {
    124     saved_args[args_name] = args[args_name];
    125       }
     120      int args_name_len = args_name.size();
     121
     122      if(args_name_len >= prefix_len) { // Only now can we substring args_name by prefix_len
     123          text_t args_prefix;
     124          if(args_name_len > prefix_len) { // substring
     125            args_prefix = substr(args_name.begin(),args_name.begin()+prefix_len);
     126          } else {
     127            args_prefix = args_name;
     128          }
     129     
     130          if (args_prefix == macro_prefix) {
     131            saved_args[args_name] = args[args_name];
     132          }
     133      }
    126134      ++args_here;
    127135    }
Note: See TracChangeset for help on using the changeset viewer.