Skip to content

Ghidra is a software reverse engineering (SRE) framework

GP-4130: Prevent word wrapping in object value columns.

Dan0e4042e6a314
diff --git a/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/model/DisplaysObjectValues.java b/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/model/DisplaysObjectValues.java
index e2ef7d4d03..9502d5ae4a 100644
--- a/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/model/DisplaysObjectValues.java
+++ b/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/model/DisplaysObjectValues.java
@@ -163,12 +163,13 @@ public interface DisplaysObjectValues {
return "";
}
if (!edge.isObject()) {
- return "<html>" + HTMLUtilities.escapeHTML(getPrimitiveValueDisplay(edge.getValue()));
+ return "<html>" +
+ HTMLUtilities.escapeHTML(getPrimitiveValueDisplay(edge.getValue()), true);
}
if (edge.isCanonical()) {
- return "<html>" + HTMLUtilities.escapeHTML(getObjectDisplay(edge));
+ return "<html>" + HTMLUtilities.escapeHTML(getObjectDisplay(edge), true);
}
- return "<html><em>" + HTMLUtilities.escapeHTML(getObjectLinkDisplay(edge)) + "</em>";
+ return "<html><em>" + HTMLUtilities.escapeHTML(getObjectLinkDisplay(edge), true) + "</em>";
}
default String getEdgeToolTip(TraceObjectValue edge) {
diff --git a/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/model/ObjectTableModel.java b/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/model/ObjectTableModel.java
index 83223e53ec..cd0e0c2e8d 100644
--- a/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/model/ObjectTableModel.java
+++ b/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/model/ObjectTableModel.java
@@ -320,7 +320,7 @@ public class ObjectTableModel extends AbstractQueryTableModel<ValueRow> {
@Override
public String getHtmlDisplay() {
return "<html>" +
- HTMLUtilities.escapeHTML(display.getPrimitiveValueDisplay(value.getValue()));
+ HTMLUtilities.escapeHTML(display.getPrimitiveValueDisplay(value.getValue()), true);
}
@Override
diff --git a/Ghidra/Framework/Gui/src/main/java/ghidra/util/HTMLUtilities.java b/Ghidra/Framework/Gui/src/main/java/ghidra/util/HTMLUtilities.java
index 0fddc97093..1510663032 100644
--- a/Ghidra/Framework/Gui/src/main/java/ghidra/util/HTMLUtilities.java
+++ b/Ghidra/Framework/Gui/src/main/java/ghidra/util/HTMLUtilities.java
@@ -138,8 +138,8 @@ public class HTMLUtilities {
"<!-- LINK " + LINK_PLACEHOLDER_CONTENT + " -->";
public static final String LINK_PLACEHOLDER_CLOSE = "<!-- /LINK -->";
- public static String HTML_SPACE = "&nbsp;";
- public static String HTML_NEW_LINE = BR;
+ public static final String HTML_SPACE = "&nbsp;";
+ public static final String HTML_NEW_LINE = BR;
/**
* Marks the given text as HTML in order to be rendered thusly by Java widgets.
@@ -595,13 +595,17 @@ public class HTMLUtilities {
* <p>
*
* @param text plain-text that might have some characters that should NOT be interpreted as HTML
+ * @param makeSpacesNonBreaking true to convert spaces into {@value #HTML_SPACE}
* @return string with any html characters replaced with equivalents
*/
- public static String escapeHTML(String text) {
+ public static String escapeHTML(String text, boolean makeSpacesNonBreaking) {
StringBuilder buffer = new StringBuilder(text.length());
text.codePoints().forEach(cp -> {
switch (cp) {
+ case ' ':
+ buffer.append(makeSpacesNonBreaking ? HTML_SPACE : " ");
+ break;
case '&':
buffer.append("&amp;");
break;
@@ -627,6 +631,17 @@ public class HTMLUtilities {
return buffer.toString();
}
+ /**
+ * Escapes any HTML special characters in the specified text.
+ *
+ * @param text plain-text that might have some characters that should NOT be interpreted as HTML
+ * @return string with any html characters replaced with equivalents
+ * @see #escapeHTML(String, boolean)
+ */
+ public static String escapeHTML(String text) {
+ return escapeHTML(text, false);
+ }
+
/**
* Tests a unicode code point (i.e., 32 bit character) to see if it needs to be escaped before
* being added to a HTML document because it is non-printable or a non-standard control