use encodePathSegment(), so that spaces are encoded as %20

This commit is contained in:
Fredrik Teschke committed 2014-12-15 22:39:51 +01:00
1 parent 135e953f36
commit d346b4e9dd
4 files changed
+12 -8

No files matched your search

@@ -8,7 +8,6 @@ import com.google.gwt.event.logical.shared.AttachEvent;
import com.google.gwt.event.logical.shared.AttachEvent.Handler;
import com.google.gwt.event.logical.shared.ValueChangeEvent;
import com.google.gwt.event.logical.shared.ValueChangeHandler;
import com.google.gwt.http.client.URL;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.user.client.ui.CaptionPanel;
import com.google.gwt.user.client.ui.Grid;
@@ -151,9 +150,9 @@ public class AddDeviceMappingToRaceLogDialog extends DataEntryDialog<DeviceMappi
throw new QRCodeURLCreationException("from cannt lie after to");
}
return baseUrlWithoutTrailingSlash + DeviceMappingConstants.APK_PATH + "?"
+ RaceLogServletConstants.PARAMS_LEADERBOARD_NAME + "=" + URL.encodeQueryString(leaderboardName) + "&"
+ RaceLogServletConstants.PARAMS_RACE_COLUMN_NAME + "=" + URL.encodeQueryString(raceColumnName)
+ "&" + RaceLogServletConstants.PARAMS_RACE_FLEET_NAME + "=" + URL.encodeQueryString(fleetName)
+ RaceLogServletConstants.PARAMS_LEADERBOARD_NAME + "=" + DeviceMappingQRCodeWidget.encode(leaderboardName) + "&"
+ RaceLogServletConstants.PARAMS_RACE_COLUMN_NAME + "=" + DeviceMappingQRCodeWidget.encode(raceColumnName)
+ "&" + RaceLogServletConstants.PARAMS_RACE_FLEET_NAME + "=" + DeviceMappingQRCodeWidget.encode(fleetName)
+ "&" + mappedItemQueryParam + "&" + DeviceMappingConstants.FROM_MILLIS + "=" + fromMillis
+ "&" + DeviceMappingConstants.TO_MILLIS + "=" + toMillis;
}
@@ -4,7 +4,6 @@ import java.util.Collection;
import com.google.gwt.event.dom.client.ChangeEvent;
import com.google.gwt.event.dom.client.ChangeHandler;
import com.google.gwt.http.client.URL;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.user.client.ui.CaptionPanel;
import com.google.gwt.user.client.ui.Grid;
@@ -99,8 +98,8 @@ public class AddDeviceMappingToRegattaLogDialog extends AbstractCancelableDialog
}
String eventIdAsString = events.getValue().id.toString();
return baseUrlWithoutTrailingSlash + DeviceMappingConstants.URL_BASE
+ "?" + DeviceMappingConstants.EVENT_ID + "=" + URL.encodeQueryString(eventIdAsString)
+ "&" + DeviceMappingConstants.LEADERBOARD_NAME + "=" + URL.encodeQueryString(leaderboardName)
+ "?" + DeviceMappingConstants.EVENT_ID + "=" + DeviceMappingQRCodeWidget.encode(eventIdAsString)
+ "&" + DeviceMappingConstants.LEADERBOARD_NAME + "=" + DeviceMappingQRCodeWidget.encode(leaderboardName)
+ "&" + mappedItemQueryParam;
}
});
@@ -4,6 +4,7 @@ import com.google.gwt.event.dom.client.KeyUpEvent;
import com.google.gwt.event.dom.client.KeyUpHandler;
import com.google.gwt.event.logical.shared.ValueChangeEvent;
import com.google.gwt.event.logical.shared.ValueChangeHandler;
import com.google.gwt.http.client.URL;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.ui.Grid;
import com.google.gwt.user.client.ui.HasHorizontalAlignment;
@@ -90,4 +91,9 @@ public abstract class BaseQRIdentifierWidget implements IsWidget {
protected void setError(String text) {
error.setText(text);
}
public static String encode(String value) {
//pathSegment instead of queryString, so that ' ' is encoded as '%20'
return URL.encodePathSegment(value);
}
}
@@ -52,6 +52,6 @@ public class DeviceMappingQRCodeWidget extends BaseQRIdentifierWidget {
throw new QRCodeURLCreationException("No item selected for mapping");
}
return urlFactory.createURL(serverUrl, mappedItemType + "=" + URL.encodeQueryString(mappedItemId));
return urlFactory.createURL(serverUrl, mappedItemType + "=" + encode(mappedItemId));
}
}