Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix GeoServerRESTPublisher::appendParameters ArrayIndexOutOfBoundsException #211

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2911,37 +2911,21 @@ protected String sanitize(String s) {
*/
private String appendParameters(NameValuePair... params) {
StringBuilder sbUrl = new StringBuilder();
// append parameters
if (params != null) {
final int paramsSize = params.length;
if (paramsSize > 0) {
int i = 0;
NameValuePair param = params[i];
while (param != null && i++ < paramsSize) {
final String name = param.getName();
final String value = param.getValue();
// success
if (name != null && !name.isEmpty() && value != null && !value.isEmpty()) {
sbUrl.append(name).append("=").append(value);
// end cycle
param = null;
if (params != null && params.length > 0) {
boolean noLongerFirst = false;
for (NameValuePair param : params){
final String name = param.getName();
final String value = param.getValue();
if (name != null && !name.isEmpty() && value != null && !value.isEmpty()) {
// valid parameter to pass
if(noLongerFirst){
// add successive parameters (if any)
sbUrl.append("&").append(name).append("=").append(value);
} else {
// next value
param = params[i];
}
}
for (; i < paramsSize; i++) {
param = params[i];
if (param != null) {
final String name = param.getName();
final String value = param.getValue();
//add the first parameter
sbUrl.append(name).append("=").append(value);
if (name != null && !name.isEmpty() && value != null && !value.isEmpty()) {
sbUrl.append("&").append(name).append("=").append(value);
}

noLongerFirst = true;
}

}
}
}
Expand Down