Changeset 30373

Show
Ignore:
Timestamp:
10.02.2016 14:53:51 (4 years ago)
Author:
kjdon
Message:

first stab at fixing diego's bug where you can't add accented values from a select in the depositor. the problem seems to be that argsstr form a get is not unicode, but from a post it is??

Location:
main/trunk/greenstone2/runtime-src/src/recpt
Files:
3 modified

Legend:

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

    r28888 r30373  
    412412  text_t::const_iterator here = argstr.begin(); 
    413413  text_t::const_iterator end = argstr.end(); 
     414  // get seems to be not unicode, while post is, so don't want to just assume encoding is 1 (not unicode) 
     415  unsigned short args_encoding = argstr.getencoding(); 
     416  cerr << "args enc = "<< args_encoding<<endl; 
    414417  text_t key, value; 
    415418  
     
    425428    safe_cgi_arg(key, value); // mitigate obvious cross-site scripting hacks in URL cgi-params 
    426429 
    427     value.setencoding(1); // other encoding 
     430    value.setencoding(args_encoding); //1 // other encoding 
    428431    // store this key=value pair 
    429432    if (!key.empty()) { 
     
    441444    // If the arg is not multi valued, then you need to decode the commas. 
    442445    if (args.getarg(key)==NULL) { 
    443       args.setarg (key, encode_commas(value), cgiarg_t::cgi_arg); 
     446      // encode_commas returns a text_t without encoding bit set 
     447      text_t newvalue = encode_commas(value); 
     448      newvalue.setencoding(args_encoding); 
     449      args.setarg (key, newvalue, cgiarg_t::cgi_arg); 
    444450    } 
    445451    else { 
     
    447453 
    448454      newvalue += "," + encode_commas(value); 
    449       newvalue.setencoding(1); // other encoding 
     455      newvalue.setencoding(args_encoding); // other encoding 
    450456      args.setarg (key, newvalue, cgiarg_t::cgi_arg); 
    451457    } 
     
    457463      if (args.lookupcgiarg(key).source == cgiarg_t::cgi_arg) newvalue += ","; 
    458464      newvalue += encode_commas(value); 
    459       newvalue.setencoding(1); // other encoding 
     465      newvalue.setencoding(args_encoding); // other encoding 
    460466      args.setarg (key, newvalue, cgiarg_t::cgi_arg); 
    461467 
  • main/trunk/greenstone2/runtime-src/src/recpt/cgiwrapper.cpp

    r28973 r30373  
    783783    // GET form data 
    784784    if (aURIStr != NULL) argstr = aURIStr; 
     785    //kjdon a get form is not unicode 
     786    argstr.setencoding(1);  
    785787      } else { 
    786788    // debugging from command line 
  • main/trunk/greenstone2/runtime-src/src/recpt/depositoraction.cpp

    r30329 r30373  
    365365          if (args_prefix == (macro_prefix+"md.")) {      
    366366            text_t args_val = args[args_name]; 
     367            cerr << "caching md arg "<<args_val<<endl; 
     368            decode_cgi_arg(args_val); 
    367369            text_t args_suffix = substr(args_name.begin()+prefix_len+3,args_name.end());  
    368370 
     
    374376              if (!mdvalues[i].empty()) { 
    375377                 
    376                 decode_cgi_arg(mdvalues[i]); 
     378                //decode_cgi_arg(mdvalues[i]); 
    377379                 
    378380                if (cached_metadata_values == "") { 
     
    805807          if (args_prefix == (macro_prefix+"md.")) {      
    806808            text_t args_val = args[args_name]; 
    807  
     809            cerr << "args val = "<<args_val<<endl; 
     810            decode_cgi_arg(args_val); 
     811            cerr << "decoded" << args_val<<endl; 
    808812            text_t args_suffix = substr(args_name.begin()+prefix_len+3,args_name.end());  
    809813 
     
    811815            splitchar (args_val.begin(), args_val.end(), ',', mdvalues); 
    812816            int numvalues = mdvalues.size(); 
    813  
     817            cerr << "numvals = "<<numvalues<<endl; 
    814818            for (int i = 0; i < numvalues; ++i) { 
    815819              if (!mdvalues[i].empty()) { 
    816                 decode_cgi_arg(mdvalues[i]); 
     820                //decode_cgi_arg(mdvalues[i]); 
    817821                metadata_file += "            <Metadata mode=\"accumulate\" name=\"";        
    818822                metadata_file += args_suffix;