Changeset 33051 for main/trunk/greenstone3
- Timestamp:
- 2019-05-06T16:23:43+12:00 (5 years ago)
- Location:
- main/trunk/greenstone3/src/java/org/greenstone/gsdl3
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
main/trunk/greenstone3/src/java/org/greenstone/gsdl3/build/GS2PerlConstructor.java
r33046 r33051 20 20 import java.io.InputStream; 21 21 import java.io.IOException; 22 //import java.io.UnsupportedEncodingException;23 //import java.net.URLEncoder;24 //import java.nio.charset.StandardCharsets;25 22 import java.util.ArrayList; 26 23 import java.util.Vector; … … 334 331 // http://www.cgi101.com/class/ch3/text.html 335 332 336 // And need to ensure that special characters won't get clobbered on Windows by perl/CGI.pm (https://www.nntp.perl.org/group/perl.perl5.porters/2016/10/msg240120.html), 337 // URL encode the query_string, as at https://stackoverflow.com/questions/10786042/java-url-encoding-of-query-string-parameters 338 339 // perl/CGI.pm doesn't like us URL encoding the entire query string such as the equal sign between each paramName and paramValue. 340 // So we URL encode each paramValue separately, which is done in GS2Construct.java::runCommand() 341 /* 342 String old_query_string = this.query_string; 343 try{ 344 this.query_string = URLEncoder.encode(this.query_string, StandardCharsets.UTF_8.name()); 345 //this.query_string = this.query_string.replace("+","%2B"); // https://stackoverflow.com/questions/1211229/in-a-url-should-spaces-be-encoded-using-20-or 346 } catch(UnsupportedEncodingException uee) { 347 logger.warn("**** Unable to encode query_string in UTF-8, so attempting to continue with the unencoded value of query_string"); 348 this.query_string = old_query_string; 349 } 350 */ 333 // And since we need to ensure that special characters won't get clobbered on Windows by perl/CGI.pm 334 // (see https://www.nntp.perl.org/group/perl.perl5.porters/2016/10/msg240120.html), 335 // each param *value* in QUERY_STRING, not QUERY_STRING in entirety, is further URL encoded, 336 // as at https://stackoverflow.com/questions/10786042/java-url-encoding-of-query-string-parameters 337 // This URL encoding of paramValues already happened in GS2Construct.java::runCommand(), so QUERY_STRING is ready now. 351 338 352 339 String[] envvars = { -
main/trunk/greenstone3/src/java/org/greenstone/gsdl3/service/GS2Construct.java
r33045 r33051 25 25 import java.io.UnsupportedEncodingException; 26 26 import java.net.URLEncoder; 27 import java.nio.charset.StandardCharsets;28 27 import java.util.Collections; 29 28 import java.util.Iterator; … … 845 844 String paramvalue = (String) entry.getValue(); 846 845 847 // And need to ensure that special characters won't get clobbered on Windows by perl/CGI.pm (https://www.nntp.perl.org/group/perl.perl5.porters/2016/10/msg240120.html), 848 // URL encode the query_string, as at https://stackoverflow.com/questions/10786042/java-url-encoding-of-query-string-parameters 849 850 // perl/CGI.pm doesn't like us URL encoding the entire query string such as the equal sign between each paramName and paramValue. 846 // This will be used to set QUERY_STRING in the environment, see build/GS2PerlConstructor.java 847 // Need to also ensure that special characters in param values won't get clobbered on Windows by perl/CGI.pm, 848 // see also https://www.nntp.perl.org/group/perl.perl5.porters/2016/10/msg240120.html 849 // Therefore URL encode CGI param values in the query_string, as at https://stackoverflow.com/questions/10786042/java-url-encoding-of-query-string-parameters 850 851 // perl/CGI.pm doesn't like us URL encoding the entire QUERY_STRING such as the equal sign between each paramName and paramValue. 851 852 // So we URL encode each paramValue separately, which is done in GS2Construct.java::runCommand() 852 853 querystring.append(paramname + "=" + urlEncodeValue(paramname, paramvalue)); … … 897 898 String oldParamVal = paramVal; 898 899 try{ 899 paramVal = URLEncoder.encode(paramVal, StandardCharsets.UTF_8.name()); 900 paramVal = URLEncoder.encode(paramVal, "UTF-8"); 901 // Better way as per https://stackoverflow.com/questions/10786042/java-url-encoding-of-query-string-parameters 902 // but our release kits' Java is too old for importing java.nio.charset.StandardCharsets 903 //paramVal = URLEncoder.encode(paramVal, StandardCharsets.UTF_8.name()); 900 904 } catch(UnsupportedEncodingException uee) { 901 905 logger.warn("**** Unable to encode query_string param " + paramName + " in UTF-8, so attempting to continue with its unencoded value."); // don't output param value to log, in case of sensitive data?
Note:
See TracChangeset
for help on using the changeset viewer.