mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2026-09-28 17:11:11 -09:00
GT-2698 code review
This commit is contained in:
@@ -48,9 +48,16 @@ public class HorizontalRuleAction extends DockingAction {
|
|||||||
|
|
||||||
// the description is meant to be used for the tooltip and is larger
|
// the description is meant to be used for the tooltip and is larger
|
||||||
String padding = " ";
|
String padding = " ";
|
||||||
setDescription("<HTML><CENTER><B>" + padding + HTMLUtilities.escapeHTML(topName) + padding +
|
setDescription("<HTML><CENTER><B>" + padding +
|
||||||
"<B><HR><B>" + padding + HTMLUtilities.escapeHTML(bottomName) + padding +
|
fixupFirstAmp(HTMLUtilities.escapeHTML(topName) + padding + "<B><HR><B>" + padding +
|
||||||
"</B></CENTER>");
|
HTMLUtilities.escapeHTML(bottomName)) +
|
||||||
|
padding + "</B></CENTER>");
|
||||||
|
}
|
||||||
|
|
||||||
|
private String fixupFirstAmp(String text) {
|
||||||
|
// add an extra & to replace the one that the MenuData will eat
|
||||||
|
int index = text.indexOf('&');
|
||||||
|
return index < 0 ? text : text.substring(0, index) + "&" + text.substring(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ import javax.swing.*;
|
|||||||
import org.junit.Assert;
|
import org.junit.Assert;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import docking.widgets.label.GDHtmlLabel;
|
import docking.widgets.label.GHtmlLabel;
|
||||||
import ghidra.app.util.html.diff.*;
|
import ghidra.app.util.html.diff.*;
|
||||||
|
|
||||||
public class DataTypeDifferTest {
|
public class DataTypeDifferTest {
|
||||||
@@ -490,24 +490,19 @@ public class DataTypeDifferTest {
|
|||||||
JPanel panel = new JPanel(new BorderLayout());
|
JPanel panel = new JPanel(new BorderLayout());
|
||||||
|
|
||||||
JPanel rightPanel = new JPanel(new BorderLayout());
|
JPanel rightPanel = new JPanel(new BorderLayout());
|
||||||
StringBuffer buffy1 = new StringBuffer(htmlLeft);
|
JLabel rightLabel = new GHtmlLabel(htmlLeft);
|
||||||
JLabel rightLabel = new GDHtmlLabel();
|
|
||||||
rightLabel.setOpaque(true);
|
rightLabel.setOpaque(true);
|
||||||
rightLabel.setBackground(Color.WHITE);
|
rightLabel.setBackground(Color.WHITE);
|
||||||
rightLabel.setVerticalAlignment(SwingConstants.TOP);
|
rightLabel.setVerticalAlignment(SwingConstants.TOP);
|
||||||
rightPanel.add(rightLabel);
|
rightPanel.add(rightLabel);
|
||||||
|
|
||||||
JPanel leftPanel = new JPanel(new BorderLayout());
|
JPanel leftPanel = new JPanel(new BorderLayout());
|
||||||
StringBuffer buffy2 = new StringBuffer(htmlRight);
|
JLabel leftLabel = new GHtmlLabel(htmlRight);
|
||||||
JLabel leftLabel = new GDHtmlLabel();
|
|
||||||
leftLabel.setOpaque(true);
|
leftLabel.setOpaque(true);
|
||||||
leftLabel.setBackground(Color.WHITE);
|
leftLabel.setBackground(Color.WHITE);
|
||||||
leftLabel.setVerticalAlignment(SwingConstants.TOP);
|
leftLabel.setVerticalAlignment(SwingConstants.TOP);
|
||||||
leftPanel.add(leftLabel);
|
leftPanel.add(leftLabel);
|
||||||
|
|
||||||
rightLabel.setText(buffy1.toString());
|
|
||||||
leftLabel.setText(buffy2.toString());
|
|
||||||
|
|
||||||
JSplitPane pane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, new JScrollPane(leftPanel),
|
JSplitPane pane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, new JScrollPane(leftPanel),
|
||||||
new JScrollPane(rightPanel));
|
new JScrollPane(rightPanel));
|
||||||
pane.setResizeWeight(.5);
|
pane.setResizeWeight(.5);
|
||||||
|
|||||||
@@ -601,9 +601,12 @@ public class HTMLUtilities {
|
|||||||
/**
|
/**
|
||||||
* Escapes any HTML special characters in the specified text.
|
* Escapes any HTML special characters in the specified text.
|
||||||
* <p>
|
* <p>
|
||||||
* Does not otherwise modify the input text or wrap lines.
|
* Does not otherwise modify the input text or wrap lines.
|
||||||
|
* <p>
|
||||||
|
* Calling this twice will result in text being double-escaped, which will not display correctly.
|
||||||
|
* <p>
|
||||||
|
* See also {@link StringEscapeUtils#escapeHtml3(String)} if you need quote-safe html encoding.
|
||||||
* <p>
|
* <p>
|
||||||
* See also {@link StringEscapeUtils#escapeHtml3(String)}.
|
|
||||||
*
|
*
|
||||||
* @param text plain-text that might have some characters that should NOT be interpreted as HTML
|
* @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
|
* @return string with any html characters replaced with equivalents
|
||||||
|
|||||||
@@ -173,4 +173,17 @@ public class HTMLUtilitiesTest {
|
|||||||
String htmlStr = HTMLUtilities.convertLinkPlaceholdersToHyperlinks(placeholderStr);
|
String htmlStr = HTMLUtilities.convertLinkPlaceholdersToHyperlinks(placeholderStr);
|
||||||
assertEquals("<A HREF=\"test\">Stuff inside <b>link</b> tag</A>", htmlStr);
|
assertEquals("<A HREF=\"test\">Stuff inside <b>link</b> tag</A>", htmlStr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testEscapeHTML() {
|
||||||
|
assertEquals("abc", HTMLUtilities.escapeHTML("abc"));
|
||||||
|
assertEquals("∢", HTMLUtilities.escapeHTML("\u2222"));
|
||||||
|
|
||||||
|
// unicode char above 0xffff encoded with 2 utf-16 characters
|
||||||
|
assertEquals("🍄", HTMLUtilities.escapeHTML("\uD83C\uDF44"));
|
||||||
|
|
||||||
|
assertEquals("<abc>", HTMLUtilities.escapeHTML("<abc>"));
|
||||||
|
assertEquals("a&b", HTMLUtilities.escapeHTML("a&b"));
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ import docking.ComponentProvider;
|
|||||||
import docking.action.DockingActionIf;
|
import docking.action.DockingActionIf;
|
||||||
import docking.help.Help;
|
import docking.help.Help;
|
||||||
import docking.help.HelpService;
|
import docking.help.HelpService;
|
||||||
import docking.widgets.label.GDHtmlLabel;
|
import docking.widgets.label.GHtmlLabel;
|
||||||
import docking.widgets.table.*;
|
import docking.widgets.table.*;
|
||||||
import docking.widgets.table.threaded.*;
|
import docking.widgets.table.threaded.*;
|
||||||
import ghidra.framework.main.FrontEndPlugin;
|
import ghidra.framework.main.FrontEndPlugin;
|
||||||
@@ -222,8 +222,8 @@ public class ProjectDataTablePanel extends JPanel {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private JLabel capacityExceededText =
|
private GHtmlLabel capacityExceededText =
|
||||||
new GDHtmlLabel("<HTML><CENTER><I>Table view disabled for very large projects, or<BR>" +
|
new GHtmlLabel("<HTML><CENTER><I>Table view disabled for very large projects, or<BR>" +
|
||||||
"if an older project/repository filesystem is in use.<BR>" +
|
"if an older project/repository filesystem is in use.<BR>" +
|
||||||
"View will remain disabled until project is closed.</I></CENTER></HTML>");
|
"View will remain disabled until project is closed.</I></CENTER></HTML>");
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user