Fix encoding/decoding of dashboard ids (one more time)
The encoding of the dashboard id on client side is done by URL.encode(...). This method is not encoding the URL component delimiter characters (e.g. '/'). This means if the dashboard ref contains '/' it is not encoded and as result the RestApiServlet on the server interprets '/' as seperator for the rest collections and the loading of the dashboard fails. When the dashboard URL is encoded on the server side by Url.encode(...) space is encoded as '+'. Decoding this on the client side in Dispatcher with URL.decodePathSegment(...) will not decode '+' to space. Instead we need to use URL.decodeQueryString(...) which makes sure to decode '+' to space. The encoding on client side should be consistent with the decoding, this is why URL.encodeQueryString(...) is used to encode the dashboard id. With the new encoding/decoding loading dashboards that contain '/' in their ref or path succeeds as well as loading dashboards that have spaces in their path. Change-Id: I4c17bd6caf517faf68b71d39656229af4eb87e99 Signed-off-by: Edwin Kempin <edwin.kempin@sap.com>
This commit is contained in:
@@ -434,8 +434,8 @@ public class Dispatcher {
|
|||||||
}
|
}
|
||||||
c = dashboardId.indexOf(":");
|
c = dashboardId.indexOf(":");
|
||||||
if (0 <= c) {
|
if (0 <= c) {
|
||||||
final String ref = URL.decode(dashboardId.substring(0, c));
|
final String ref = URL.decodeQueryString(dashboardId.substring(0, c));
|
||||||
final String path = URL.decode(dashboardId.substring(c + 1));
|
final String path = URL.decodeQueryString(dashboardId.substring(c + 1));
|
||||||
DashboardList.get(new Project.NameKey(project), ref + ":" + path, cb);
|
DashboardList.get(new Project.NameKey(project), ref + ":" + path, cb);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@@ -50,11 +50,11 @@ public class DashboardList extends NativeList<DashboardInfo> {
|
|||||||
private static String encodeDashboardId(String dashboardId) {
|
private static String encodeDashboardId(String dashboardId) {
|
||||||
int c = dashboardId.indexOf(":");
|
int c = dashboardId.indexOf(":");
|
||||||
if (0 <= c) {
|
if (0 <= c) {
|
||||||
final String ref = URL.encode(dashboardId.substring(0, c));
|
final String ref = URL.encodeQueryString(dashboardId.substring(0, c));
|
||||||
final String path = URL.encode(dashboardId.substring(c + 1));
|
final String path = URL.encodeQueryString(dashboardId.substring(c + 1));
|
||||||
return ref + ":" + path;
|
return ref + ":" + path;
|
||||||
} else {
|
} else {
|
||||||
return URL.encode(dashboardId);
|
return URL.encodeQueryString(dashboardId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user