ACCUMULO-2067 urlencode the table id used in the link.
Project: http://git-wip-us.apache.org/repos/asf/accumulo/repo Commit: http://git-wip-us.apache.org/repos/asf/accumulo/commit/e7f68b58 Tree: http://git-wip-us.apache.org/repos/asf/accumulo/tree/e7f68b58 Diff: http://git-wip-us.apache.org/repos/asf/accumulo/diff/e7f68b58 Branch: refs/heads/master Commit: e7f68b586f8317b1e1e94aa56e6adbeacc10670f Parents: 92077a8 Author: Josh Elser <els...@apache.org> Authored: Fri Dec 20 01:45:55 2013 -0500 Committer: Josh Elser <els...@apache.org> Committed: Fri Dec 20 01:45:55 2013 -0500 ---------------------------------------------------------------------- .../monitor/util/celltypes/TableLinkType.java | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/accumulo/blob/e7f68b58/server/monitor/src/main/java/org/apache/accumulo/monitor/util/celltypes/TableLinkType.java ---------------------------------------------------------------------- diff --git a/server/monitor/src/main/java/org/apache/accumulo/monitor/util/celltypes/TableLinkType.java b/server/monitor/src/main/java/org/apache/accumulo/monitor/util/celltypes/TableLinkType.java index 03bd06b..39a932e 100644 --- a/server/monitor/src/main/java/org/apache/accumulo/monitor/util/celltypes/TableLinkType.java +++ b/server/monitor/src/main/java/org/apache/accumulo/monitor/util/celltypes/TableLinkType.java @@ -16,13 +16,18 @@ */ package org.apache.accumulo.monitor.util.celltypes; +import java.io.UnsupportedEncodingException; +import java.net.URLEncoder; import java.util.Map; +import org.apache.accumulo.core.Constants; import org.apache.accumulo.core.client.impl.Tables; import org.apache.accumulo.server.client.HdfsZooInstance; +import org.apache.log4j.Logger; public class TableLinkType extends CellType<String> { + private static final Logger log = Logger.getLogger(TableLinkType.class); private Map<String,String> tidToNameMap; public TableLinkType() { @@ -34,7 +39,15 @@ public class TableLinkType extends CellType<String> { if (obj == null) return "-"; String tableId = (String) obj; - return String.format("<a href='/tables?t=%s'>%s</a>", tableId, displayName(tableId)); + String encodedTableId = tableId; + // Encode the tableid we use in the link so we construct a correct url + // e.g. the root table's id of "+r" would not be interpreted properly + try { + encodedTableId = URLEncoder.encode(tableId, Constants.UTF8.name()); + } catch (UnsupportedEncodingException e) { + log.error("Could not urlencode tableId: " + encodedTableId); + } + return String.format("<a href='/tables?t=%s'>%s</a>", encodedTableId, displayName(tableId)); } private String displayName(String tableId) {