GT-2698 - fix html escaping to use simpler method.

This commit is contained in:
dev747368
2019-04-15 18:18:15 -04:00
parent 6448f0da8f
commit fa7173f9ab
60 changed files with 109 additions and 119 deletions
@@ -162,7 +162,7 @@ public class SampleTableProvider extends ComponentProviderAdapter implements Opt
StringBuilder buffer = new StringBuilder(); StringBuilder buffer = new StringBuilder();
buffer.append("Writing the following objects to file: "); buffer.append("Writing the following objects to file: ");
buffer.append(HTMLUtilities.friendlyEncodeHTML(fileChooserPanel.getFileName())); buffer.append(HTMLUtilities.escapeHTML(fileChooserPanel.getFileName()));
List<FunctionStatsRowObject> selectedObjects = filterTable.getSelectedRowObjects(); List<FunctionStatsRowObject> selectedObjects = filterTable.getSelectedRowObjects();
for (FunctionStatsRowObject stats : selectedObjects) { for (FunctionStatsRowObject stats : selectedObjects) {
@@ -156,8 +156,8 @@ public class ConflictInfoPanel extends JPanel {
} }
private void addAddress(StringBuffer buf, Address addr) { private void addAddress(StringBuffer buf, Address addr) {
buf.append("<font color=\"#990000\">" + HTMLUtilities.friendlyEncodeHTML(addr.toString()) + buf.append(
"</font>"); "<font color=\"#990000\">" + HTMLUtilities.escapeHTML(addr.toString()) + "</font>");
} }
private void updateWest() { private void updateWest() {
@@ -524,9 +524,9 @@ public class VariousChoicesPanel extends ConflictPanel {
(displayedFont != null) ? getFontMetrics(displayedFont) : null; (displayedFont != null) ? getFontMetrics(displayedFont) : null;
int stringWidth = int stringWidth =
(fontMetrics != null) ? fontMetrics.stringWidth(displayedText) : 0; (fontMetrics != null) ? fontMetrics.stringWidth(displayedText) : 0;
setToolTipText((stringWidth > displayedWidth) setToolTipText(
? "<html>" + HTMLUtilities.friendlyEncodeHTML(text) (stringWidth > displayedWidth) ? "<html>" + HTMLUtilities.escapeHTML(text)
: null); : null);
} }
@Override @Override
@@ -480,9 +480,9 @@ public class VerticalChoicesPanel extends ConflictPanel {
(displayedFont != null) ? getFontMetrics(displayedFont) : null; (displayedFont != null) ? getFontMetrics(displayedFont) : null;
int stringWidth = int stringWidth =
(fontMetrics != null) ? fontMetrics.stringWidth(displayedText) : 0; (fontMetrics != null) ? fontMetrics.stringWidth(displayedText) : 0;
setToolTipText((stringWidth > displayedWidth) setToolTipText(
? "<html>" + HTMLUtilities.friendlyEncodeHTML(text) (stringWidth > displayedWidth) ? "<html>" + HTMLUtilities.escapeHTML(text)
: null); : null);
} }
@Override @Override
@@ -240,7 +240,7 @@ public class ConflictUtility {
*/ */
public static String getAddressString(Address address) { public static String getAddressString(Address address) {
return colorString(ADDRESS_COLOR, return colorString(ADDRESS_COLOR,
((address != null) ? HTMLUtilities.friendlyEncodeHTML(address.toString()) : "")); ((address != null) ? HTMLUtilities.escapeHTML(address.toString()) : ""));
} }
/** /**
@@ -251,8 +251,7 @@ public class ConflictUtility {
*/ */
public static String getAddressString(Address address, boolean showAddressSpace) { public static String getAddressString(Address address, boolean showAddressSpace) {
return colorString(ADDRESS_COLOR, return colorString(ADDRESS_COLOR,
((address != null) ((address != null) ? HTMLUtilities.escapeHTML(address.toString(showAddressSpace))
? HTMLUtilities.friendlyEncodeHTML(address.toString(showAddressSpace))
: "")); : ""));
} }
@@ -298,7 +298,7 @@ class AnalyzeAllOpenProgramsTask extends Task {
buffy.append("<TR>"); buffy.append("<TR>");
buffy.append("<TD>"); buffy.append("<TD>");
buffy.append(specialFontOpen); buffy.append(specialFontOpen);
buffy.append(HTMLUtilities.friendlyEncodeHTML(program.getName())); buffy.append(HTMLUtilities.escapeHTML(program.getName()));
buffy.append(specialFontClose); buffy.append(specialFontClose);
buffy.append("</TD>"); buffy.append("</TD>");
buffy.append("<TD>"); buffy.append("<TD>");
@@ -325,7 +325,7 @@ class AnalyzeAllOpenProgramsTask extends Task {
for (Program program : invalidList) { for (Program program : invalidList) {
buffy.append("<TR>"); buffy.append("<TR>");
buffy.append("<TD>"); buffy.append("<TD>");
buffy.append(HTMLUtilities.friendlyEncodeHTML(program.getName())); buffy.append(HTMLUtilities.escapeHTML(program.getName()));
buffy.append("</TD>"); buffy.append("</TD>");
buffy.append("<TD>"); buffy.append("<TD>");
buffy.append(program.getLanguageID()); buffy.append(program.getLanguageID());
@@ -1098,7 +1098,7 @@ public class AutoAnalysisManager implements DomainObjectListener, DomainObjectCl
} }
if (GhidraProgramUtilities.shouldAskToAnalyze(program)) { if (GhidraProgramUtilities.shouldAskToAnalyze(program)) {
int answer = OptionDialog.showYesNoDialog(tool.getToolFrame(), "Analyze", int answer = OptionDialog.showYesNoDialog(tool.getToolFrame(), "Analyze",
"<html>" + HTMLUtilities.friendlyEncodeHTML(program.getDomainFile().getName()) + "<html>" + HTMLUtilities.escapeHTML(program.getDomainFile().getName()) +
" has not been analyzed. Would you like to analyze it now?"); " has not been analyzed. Would you like to analyze it now?");
boolean analyzed = answer == OptionDialog.OPTION_ONE; boolean analyzed = answer == OptionDialog.OPTION_ONE;
GhidraProgramUtilities.setAnalyzedFlag(program, analyzed); GhidraProgramUtilities.setAnalyzedFlag(program, analyzed);
@@ -118,11 +118,11 @@ public class BookmarkNavigator {
String cat = bookmarks[i].getCategory(); String cat = bookmarks[i].getCategory();
if (cat != null && cat.length() != 0) { if (cat != null && cat.length() != 0) {
buf.append(" ["); buf.append(" [");
buf.append(HTMLUtilities.friendlyEncodeHTML(cat)); buf.append(HTMLUtilities.escapeHTML(cat));
buf.append("]"); buf.append("]");
} }
buf.append(": "); buf.append(": ");
buf.append(HTMLUtilities.friendlyEncodeHTML(bookmarks[i].getComment())); buf.append(HTMLUtilities.escapeHTML(bookmarks[i].getComment()));
} }
return buf.toString(); return buf.toString();
} }
@@ -93,7 +93,7 @@ public class ProgramAddressRelationshipListingHover extends AbstractConfigurable
MemoryBlock block = program.getMemory().getBlock(loc); MemoryBlock block = program.getMemory().getBlock(loc);
long memblockOffset = loc.subtract(block.getStart()); long memblockOffset = loc.subtract(block.getStart());
appendTableRow(sb, "Memory Block Offset", HTMLUtilities.friendlyEncodeHTML(block.getName()), appendTableRow(sb, "Memory Block Offset", HTMLUtilities.escapeHTML(block.getName()),
memblockOffset); memblockOffset);
addFunctionInfo(program, loc, sb); addFunctionInfo(program, loc, sb);
@@ -143,8 +143,8 @@ public class ProgramAddressRelationshipListingHover extends AbstractConfigurable
Function function = program.getFunctionManager().getFunctionContaining(loc); Function function = program.getFunctionManager().getFunctionContaining(loc);
if (function != null) { if (function != null) {
long functionOffset = loc.subtract(function.getEntryPoint()); long functionOffset = loc.subtract(function.getEntryPoint());
appendTableRow(sb, "Function Offset", appendTableRow(sb, "Function Offset", HTMLUtilities.escapeHTML(function.getName()),
HTMLUtilities.friendlyEncodeHTML(function.getName()), functionOffset); functionOffset);
} }
} }
@@ -1466,7 +1466,7 @@ public abstract class CompEditorModel extends CompositeEditorModel {
originalIsChanging = true; originalIsChanging = true;
try { try {
if (hadChanges) { if (hadChanges) {
String message = "<html>" + HTMLUtilities.friendlyEncodeHTML(oldName) + String message = "<html>" + HTMLUtilities.escapeHTML(oldName) +
" has changed outside the editor.<br>" + " has changed outside the editor.<br>" +
"Discard edits & reload the " + getTypeName() + "?"; "Discard edits & reload the " + getTypeName() + "?";
String title = "Reload " + getTypeName() + " Editor?"; String title = "Reload " + getTypeName() + " Editor?";
@@ -1570,7 +1570,7 @@ public abstract class CompEditorModel extends CompositeEditorModel {
consideringReplacedDataType = true; consideringReplacedDataType = true;
try { try {
String message = String message =
"<html>" + HTMLUtilities.friendlyEncodeHTML(oldPath.getPath()) + "<html>" + HTMLUtilities.escapeHTML(oldPath.getPath()) +
" has changed outside the editor.<br>" + " has changed outside the editor.<br>" +
"Discard edits & reload the " + getTypeName() + "?"; "Discard edits & reload the " + getTypeName() + "?";
String title = "Reload " + getTypeName() + " Editor?"; String title = "Reload " + getTypeName() + " Editor?";
@@ -302,7 +302,7 @@ public class CParserPlugin extends ProgramPlugin {
list.add(openDTmanagers[i]); list.add(openDTmanagers[i]);
if (!(openDTmanagers[i] instanceof BuiltInDataTypeManager)) { if (!(openDTmanagers[i] instanceof BuiltInDataTypeManager)) {
htmlNamesList += "<li><b>" + htmlNamesList += "<li><b>" +
HTMLUtilities.friendlyEncodeHTML(openDTmanagers[i].getName()) + "</b></li>"; HTMLUtilities.escapeHTML(openDTmanagers[i].getName()) + "</b></li>";
} }
} }
openDTmanagers = list.toArray(new DataTypeManager[0]); openDTmanagers = list.toArray(new DataTypeManager[0]);
@@ -569,8 +569,7 @@ public class CreateStructureDialog extends DialogComponentProvider {
message = EXISITING_STRUCTURE_STATUS_PREFIX; message = EXISITING_STRUCTURE_STATUS_PREFIX;
} }
setStatusText( setStatusText("<HTML>" + message + "<BR>\"" + HTMLUtilities.escapeHTML(name) + "\"");
"<HTML>" + message + "<BR>\"" + HTMLUtilities.friendlyEncodeHTML(name) + "\"");
} }
// this class is used instead of a cell renderer so that sorting will // this class is used instead of a cell renderer so that sorting will
@@ -53,7 +53,7 @@ public class DataOrganizationDialog extends DialogComponentProvider {
JPanel headerPanel = new JPanel(); JPanel headerPanel = new JPanel();
headerPanel.add(new GHtmlLabel("<HTML>Alignment Information for <b>" + headerPanel.add(new GHtmlLabel("<HTML>Alignment Information for <b>" +
HTMLUtilities.friendlyEncodeHTML(dataTypeManager.getName()) + "</b>.</HTML>")); HTMLUtilities.escapeHTML(dataTypeManager.getName()) + "</b>.</HTML>"));
alignPanel = new DataOrganizationPanel(); alignPanel = new DataOrganizationPanel();
alignPanel.setOrganization(dataOrganization); alignPanel.setOrganization(dataOrganization);
@@ -65,8 +65,8 @@ class DataTypeComparePanel extends JPanel {
leftPanelLabel.setBorder(BorderFactory.createEmptyBorder(2, 8, 2, 0)); leftPanelLabel.setBorder(BorderFactory.createEmptyBorder(2, 8, 2, 0));
rightPanelLabel.setBorder(BorderFactory.createEmptyBorder(2, 8, 2, 0)); rightPanelLabel.setBorder(BorderFactory.createEmptyBorder(2, 8, 2, 0));
setLabelText(leftPanelLabel, HTMLUtilities.friendlyEncodeHTML(clientName) + ":"); setLabelText(leftPanelLabel, HTMLUtilities.escapeHTML(clientName) + ":");
setLabelText(rightPanelLabel, HTMLUtilities.friendlyEncodeHTML(sourceName) + ":"); setLabelText(rightPanelLabel, HTMLUtilities.escapeHTML(sourceName) + ":");
add(leftPanel); add(leftPanel);
add(rightPanel); add(rightPanel);
@@ -334,8 +334,8 @@ public class DataTypeSynchronizer {
buffy.append("<TR BORDER=LEFT>"); buffy.append("<TR BORDER=LEFT>");
buffy.append("<TD VALIGN=\"TOP\">"); buffy.append("<TD VALIGN=\"TOP\">");
buffy.append("<B>").append( buffy.append("<B>").append(HTMLUtilities.escapeHTML(dataTypeManager.getName())).append(
HTMLUtilities.friendlyEncodeHTML(dataTypeManager.getName())).append("</B><HR NOSHADE>"); "</B><HR NOSHADE>");
buffy.append(htmlContent); buffy.append(htmlContent);
// horizontal spacer below the inner table in order to force a minimum width // horizontal spacer below the inner table in order to force a minimum width
@@ -347,8 +347,8 @@ public class DataTypeSynchronizer {
buffy.append("</TD>"); buffy.append("</TD>");
buffy.append("<TD VALIGN=\"TOP\">"); buffy.append("<TD VALIGN=\"TOP\">");
buffy.append("<B>").append( buffy.append("<B>").append(HTMLUtilities.escapeHTML(sourceArchive.getName())).append(
HTMLUtilities.friendlyEncodeHTML(sourceArchive.getName())).append("</B><HR NOSHADE>"); "</B><HR NOSHADE>");
buffy.append(otherContent); buffy.append(otherContent);
@@ -197,8 +197,8 @@ class OpenDomainFileTask extends Task {
if (dfile.isInWritableProject() && dfile.canRecover()) { if (dfile.isInWritableProject() && dfile.canRecover()) {
Runnable r = () -> { Runnable r = () -> {
int option = OptionDialog.showYesNoDialog(null, "Crash Recovery Data Found", int option = OptionDialog.showYesNoDialog(null, "Crash Recovery Data Found",
"<html>" + HTMLUtilities.friendlyEncodeHTML(dfile.getName()) + "<html>" + HTMLUtilities.escapeHTML(dfile.getName()) + " has crash data.<br>" +
" has crash data.<br>" + "Would you like to recover unsaved changes?"); "Would you like to recover unsaved changes?");
recoverFile[0] = (option == OptionDialog.OPTION_ONE); recoverFile[0] = (option == OptionDialog.OPTION_ONE);
}; };
SwingUtilities.invokeAndWait(r); SwingUtilities.invokeAndWait(r);
@@ -62,7 +62,7 @@ public class CreatePointerAction extends DockingAction {
Msg.showInfo(getClass(), gTree, "Pointers Filter Enabled", Msg.showInfo(getClass(), gTree, "Pointers Filter Enabled",
"<html>Newly created pointer is filtered out of view.<br><br>Toggle the " + "<html>Newly created pointer is filtered out of view.<br><br>Toggle the " +
"<b>Filter Pointers " + "Action</b> to view the pointer<br>Pointer: " + "<b>Filter Pointers " + "Action</b> to view the pointer<br>Pointer: " +
HTMLUtilities.friendlyEncodeHTML(newManager.getName() + newPath)); HTMLUtilities.escapeHTML(newManager.getName() + newPath));
return; return;
} }
@@ -94,7 +94,7 @@ public class DeleteArchiveAction extends DockingAction {
if (OptionDialog.showOptionDialogWithCancelAsDefaultButton(gTree, if (OptionDialog.showOptionDialogWithCancelAsDefaultButton(gTree,
"Confirm Delete Operation", "Confirm Delete Operation",
"<html><b>Are you sure you want to delete archive: " + "<html><b>Are you sure you want to delete archive: " +
HTMLUtilities.friendlyEncodeHTML(node.getName()) + "?<br><br>" + HTMLUtilities.escapeHTML(node.getName()) + "?<br><br>" +
"<font color=\"red\">(WARNING: This action will permanently " + "<font color=\"red\">(WARNING: This action will permanently " +
"delete the file from disk.)</font></b>", "delete the file from disk.)</font></b>",
"Yes", OptionDialog.QUESTION_MESSAGE) != OptionDialog.OPTION_ONE) { "Yes", OptionDialog.QUESTION_MESSAGE) != OptionDialog.OPTION_ONE) {
@@ -77,7 +77,7 @@ public class RemoveInvalidArchiveFromProgramAction extends DockingAction {
if (OptionDialog.showOptionDialog(gtree, "Confirm Remove Invalid Archive(s)", if (OptionDialog.showOptionDialog(gtree, "Confirm Remove Invalid Archive(s)",
"<html><b>Are you sure you want to delete archive: " + "<html><b>Are you sure you want to delete archive: " +
HTMLUtilities.friendlyEncodeHTML(invalidArchiveNode.getName()) + HTMLUtilities.escapeHTML(invalidArchiveNode.getName()) +
" from the program?<br><br>" + " from the program?<br><br>" +
"<font color=\"red\">(WARNING: This action will disassociate " + "<font color=\"red\">(WARNING: This action will disassociate " +
"all datatypes in the program from this archive.)</font></b>", "all datatypes in the program from this archive.)</font></b>",
@@ -398,8 +398,8 @@ public class EnumEditorProvider extends ComponentProviderAdapter
newVal = "Missing"; newVal = "Missing";
} }
msg.append(String.format("<li>%s: 0x%s \u2192 <font color=#ff0000>%s</font></li>", msg.append(String.format("<li>%s: 0x%s \u2192 <font color=#ff0000>%s</font></li>",
HTMLUtilities.friendlyEncodeHTML(field), HTMLUtilities.escapeHTML(field), Long.toHexString(originalEnum.getValue(field)),
Long.toHexString(originalEnum.getValue(field)), newVal)); newVal));
} }
msg.append("</ul>"); msg.append("</ul>");
msg.append( msg.append(
@@ -140,7 +140,7 @@ public class CategoryNode extends GTreeLazyNode implements DataTypeTreeNode {
@Override @Override
public String getToolTip() { public String getToolTip() {
return "<html>" + HTMLUtilities.friendlyEncodeHTML(category.getCategoryPathName()); return "<html>" + HTMLUtilities.escapeHTML(category.getCategoryPathName());
} }
@Override @Override
@@ -103,7 +103,7 @@ public class DomainFileArchiveNode extends ArchiveNode {
public String getToolTip() { public String getToolTip() {
DomainFile file = ((DomainFileArchive) archive).getDomainFile(); DomainFile file = ((DomainFileArchive) archive).getDomainFile();
if (file != null) { if (file != null) {
return "<html>" + HTMLUtilities.friendlyEncodeHTML(file.getPathname()); return "<html>" + HTMLUtilities.escapeHTML(file.getPathname());
} }
return "[Unsaved New Domain File Archive]"; return "[Unsaved New Domain File Archive]";
} }
@@ -54,7 +54,7 @@ public class FileArchiveNode extends ArchiveNode {
public String getToolTip() { public String getToolTip() {
ResourceFile file = fileArchive.getFile(); ResourceFile file = fileArchive.getFile();
if (file != null) { if (file != null) {
return "<html>" + HTMLUtilities.friendlyEncodeHTML(file.getAbsolutePath()); return "<html>" + HTMLUtilities.escapeHTML(file.getAbsolutePath());
} }
return "[Unsaved New Archive]"; return "[Unsaved New Archive]";
} }
@@ -44,7 +44,7 @@ public class InvalidArchiveNode extends ArchiveNode {
ArchiveType archiveType = ((InvalidFileArchive) archive).getArchiveType(); ArchiveType archiveType = ((InvalidFileArchive) archive).getArchiveType();
String type = archiveType == ArchiveType.FILE ? "File" : "Project"; String type = archiveType == ArchiveType.FILE ? "File" : "Project";
return "<html>Unable to locate " + type + " data type archive: " + return "<html>Unable to locate " + type + " data type archive: " +
HTMLUtilities.friendlyEncodeHTML(archive.getName()); HTMLUtilities.escapeHTML(archive.getName());
} }
@Override @Override
@@ -29,7 +29,7 @@ public class ProgramArchiveNode extends DomainFileArchiveNode {
public String getToolTip() { public String getToolTip() {
DomainFile file = ((ProgramArchive) archive).getDomainFile(); DomainFile file = ((ProgramArchive) archive).getDomainFile();
if (file != null) { if (file != null) {
return "<html>" + HTMLUtilities.friendlyEncodeHTML(file.getPathname()); return "<html>" + HTMLUtilities.escapeHTML(file.getPathname());
} }
return "[Unsaved New Program Archive]"; return "[Unsaved New Program Archive]";
} }
@@ -37,7 +37,7 @@ public class ProjectArchiveNode extends DomainFileArchiveNode {
public String getToolTip() { public String getToolTip() {
DomainFile file = ((ProjectArchive) archive).getDomainFile(); DomainFile file = ((ProjectArchive) archive).getDomainFile();
if (file != null) { if (file != null) {
return "<html>" + HTMLUtilities.friendlyEncodeHTML(file.getPathname()); return "<html>" + HTMLUtilities.escapeHTML(file.getPathname());
} }
return "[Unsaved New Project Archive]"; return "[Unsaved New Project Archive]";
} }
@@ -440,7 +440,7 @@ public class DisassembledViewPlugin extends ProgramPlugin implements DomainObjec
setFont(font); setFont(font);
setToolTipText(TOOLTIP_TEXT_PREPEND + setToolTipText(TOOLTIP_TEXT_PREPEND +
HTMLUtilities.friendlyEncodeHTML(currentLocation.getAddress().toString())); HTMLUtilities.escapeHTML(currentLocation.getAddress().toString()));
// make sure the first value is highlighted to indicate // make sure the first value is highlighted to indicate
// that it is the selected program location // that it is the selected program location
@@ -321,10 +321,9 @@ abstract class FlowArrow {
} }
public String getDisplayString() { public String getDisplayString() {
return "<html><table><tr><td>start</td><td>" + return "<html><table><tr><td>start</td><td>" + HTMLUtilities.escapeHTML(start.toString()) +
HTMLUtilities.friendlyEncodeHTML(start.toString()) + "</td><tr><td>end</td><td>" + "</td><tr><td>end</td><td>" + HTMLUtilities.escapeHTML(end.toString()) +
HTMLUtilities.friendlyEncodeHTML(end.toString()) + "</td><tr><td>ref type</td><td>" + "</td><tr><td>ref type</td><td>" + refType + "</td></tr></table>";
refType + "</td></tr></table>";
} }
@Override @Override
@@ -50,7 +50,7 @@ public class FunctionTagList extends JList<FunctionTag> {
return "<no comment set>"; return "<no comment set>";
} }
return "<html>" + HTMLUtilities.friendlyEncodeHTML(tag.getComment()); return "<html>" + HTMLUtilities.escapeHTML(tag.getComment());
} }
return ""; return "";
@@ -90,11 +90,11 @@ public class AddressTypeOverviewColorService
AddressType addressType = getAddressType(address); AddressType addressType = getAddressType(address);
StringBuffer buffer = new StringBuffer(); StringBuffer buffer = new StringBuffer();
buffer.append("<b>"); buffer.append("<b>");
buffer.append(HTMLUtilities.friendlyEncodeHTML(getName())); buffer.append(HTMLUtilities.escapeHTML(getName()));
buffer.append("</b>\n"); buffer.append("</b>\n");
buffer.append(addressType.getDescription()); buffer.append(addressType.getDescription());
buffer.append(" ("); buffer.append(" (");
buffer.append(HTMLUtilities.friendlyEncodeHTML(getBlockName(address))); buffer.append(HTMLUtilities.escapeHTML(getBlockName(address)));
buffer.append(" "); buffer.append(" ");
buffer.append(address); buffer.append(address);
buffer.append(" )"); buffer.append(" )");
@@ -88,17 +88,17 @@ public class EntropyOverviewColorService implements OverviewColorService {
double entropy = (entropyScaled * 8.0d) / 255; // convert back from palette scale to original entropy value double entropy = (entropyScaled * 8.0d) / 255; // convert back from palette scale to original entropy value
StringBuilder buffer = new StringBuilder(); StringBuilder buffer = new StringBuilder();
buffer.append("<b>"); buffer.append("<b>");
buffer.append(HTMLUtilities.friendlyEncodeHTML(getName())); buffer.append(HTMLUtilities.escapeHTML(getName()));
buffer.append("</b>\n"); buffer.append("</b>\n");
buffer.append(" "); buffer.append(" ");
buffer.append(formatter.format(entropy)); buffer.append(formatter.format(entropy));
buffer.append(" "); buffer.append(" ");
buffer.append(HTMLUtilities.friendlyEncodeHTML(getKnotName(entropyScaled))); buffer.append(HTMLUtilities.escapeHTML(getKnotName(entropyScaled)));
buffer.append(" "); buffer.append(" ");
buffer.append(" &nbsp&nbsp&nbsp("); buffer.append(" &nbsp&nbsp&nbsp(");
buffer.append(HTMLUtilities.friendlyEncodeHTML(getBlockName(address))); buffer.append(HTMLUtilities.escapeHTML(getBlockName(address)));
buffer.append(" "); buffer.append(" ");
buffer.append(HTMLUtilities.friendlyEncodeHTML(address.toString())); buffer.append(HTMLUtilities.escapeHTML(address.toString()));
buffer.append(" )"); buffer.append(" )");
return HTMLUtilities.toWrappedHTML(buffer.toString(), 0); return HTMLUtilities.toWrappedHTML(buffer.toString(), 0);
} }
@@ -558,7 +558,7 @@ public class ProgramManagerPlugin extends Plugin implements ProgramManager {
Program program = context.getProgram(); Program program = context.getProgram();
String programName = "'" + program.getDomainFile().getName() + "'"; String programName = "'" + program.getDomainFile().getName() + "'";
getMenuBarData().setMenuItemName("&Close " + programName); getMenuBarData().setMenuItemName("&Close " + programName);
setDescription("<html>Close " + HTMLUtilities.friendlyEncodeHTML(programName)); setDescription("<html>Close " + HTMLUtilities.escapeHTML(programName));
return true; return true;
} }
}; };
@@ -266,7 +266,7 @@ class ProgramSaveManager {
if (!df.isInWritableProject()) { if (!df.isInWritableProject()) {
return OptionDialog.showOptionDialog(tool.getToolFrame(), "Program Changed", return OptionDialog.showOptionDialog(tool.getToolFrame(), "Program Changed",
HTMLUtilities.lineWrapWithHTMLLineBreaks( HTMLUtilities.lineWrapWithHTMLLineBreaks(
"<html>Viewed file '" + HTMLUtilities.friendlyEncodeHTML(filename) + "<html>Viewed file '" + HTMLUtilities.escapeHTML(filename) +
"' has been changed. \n" + "If you continue, your changes will be lost!"), "' has been changed. \n" + "If you continue, your changes will be lost!"),
"Continue", OptionDialog.QUESTION_MESSAGE) != OptionDialog.CANCEL_OPTION; "Continue", OptionDialog.QUESTION_MESSAGE) != OptionDialog.CANCEL_OPTION;
} }
@@ -274,16 +274,15 @@ class ProgramSaveManager {
if (df.isReadOnly()) { if (df.isReadOnly()) {
return OptionDialog.showOptionDialog(tool.getToolFrame(), "Program Changed", return OptionDialog.showOptionDialog(tool.getToolFrame(), "Program Changed",
HTMLUtilities.lineWrapWithHTMLLineBreaks( HTMLUtilities.lineWrapWithHTMLLineBreaks(
"<html>Read-only file '" + HTMLUtilities.friendlyEncodeHTML(filename) + "<html>Read-only file '" + HTMLUtilities.escapeHTML(filename) +
"' has been changed. \n" + "If you continue, your changes will be lost!"), "' has been changed. \n" + "If you continue, your changes will be lost!"),
"Continue", OptionDialog.QUESTION_MESSAGE) != OptionDialog.CANCEL_OPTION; "Continue", OptionDialog.QUESTION_MESSAGE) != OptionDialog.CANCEL_OPTION;
} }
int result = OptionDialog.showOptionDialog(tool.getToolFrame(), "Save Program?", int result = OptionDialog.showOptionDialog(tool.getToolFrame(), "Save Program?",
HTMLUtilities.lineWrapWithHTMLLineBreaks( HTMLUtilities.lineWrapWithHTMLLineBreaks("<html>" + HTMLUtilities.escapeHTML(filename) +
"<html>" + HTMLUtilities.friendlyEncodeHTML(filename) + " has changed.\nDo you want to save it?"),
" has changed.\nDo you want to save it?"),
"&Save", "Do&n't Save", OptionDialog.QUESTION_MESSAGE); "&Save", "Do&n't Save", OptionDialog.QUESTION_MESSAGE);
if (result == OptionDialog.CANCEL_OPTION) { if (result == OptionDialog.CANCEL_OPTION) {
@@ -69,7 +69,7 @@ public class RedoAction extends ProgramContextAction {
String programName = program.getDomainFile().getName(); String programName = program.getDomainFile().getName();
getMenuBarData().setMenuItemName("Redo " + programName); getMenuBarData().setMenuItemName("Redo " + programName);
String tip = HTMLUtilities.toWrappedHTML( String tip = HTMLUtilities.toWrappedHTML(
"Redo " + HTMLUtilities.friendlyEncodeHTML(program.getRedoName())); "Redo " + HTMLUtilities.escapeHTML(program.getRedoName()));
setDescription(tip); setDescription(tip);
return true; return true;
} }
@@ -76,7 +76,7 @@ public class UndoAction extends ProgramContextAction {
String programName = program.getDomainFile().getName(); String programName = program.getDomainFile().getName();
getMenuBarData().setMenuItemName("Undo " + programName); getMenuBarData().setMenuItemName("Undo " + programName);
String tip = HTMLUtilities.toWrappedHTML( String tip = HTMLUtilities.toWrappedHTML(
"Undo " + HTMLUtilities.friendlyEncodeHTML(program.getUndoName())); "Undo " + HTMLUtilities.escapeHTML(program.getUndoName()));
setDescription(tip); setDescription(tip);
return true; return true;
} }
@@ -138,7 +138,7 @@ public class SymbolNode extends GTreeSlowLoadingNode implements SymbolTreeNode {
@Override @Override
public String getToolTip() { public String getToolTip() {
return "<html>" + HTMLUtilities.friendlyEncodeHTML(symbol.getName(true)); return "<html>" + HTMLUtilities.escapeHTML(symbol.getName(true));
} }
@Override @Override
@@ -388,7 +388,7 @@ public abstract class GhidraScript extends FlatProgramAPI {
protected boolean promptToKeepChangesOnException() { protected boolean promptToKeepChangesOnException() {
String message = "<html>Encountered exception running script \"" + String message = "<html>Encountered exception running script \"" +
HTMLUtilities.friendlyEncodeHTML(sourceFile.getName()) + HTMLUtilities.escapeHTML(sourceFile.getName()) +
"\".<br><br>Keep the changes to the program?"; "\".<br><br>Keep the changes to the program?";
//@formatter:off //@formatter:off
int choice = int choice =
@@ -434,22 +434,20 @@ public class ScriptInfo {
*/ */
public String getToolTipText() { public String getToolTipText() {
String htmlDescription = (description == null) ? "No Description" String htmlDescription = (description == null) ? "No Description"
: HTMLUtilities.friendlyEncodeHTML(description).replaceAll("\n", : HTMLUtilities.escapeHTML(description).replaceAll("\n",
HTML_NEW_LINE + HTML_SPACE); HTML_NEW_LINE + HTML_SPACE);
String htmlAuthor = HTMLUtilities.bold("Author:") + HTML_SPACE + String htmlAuthor = HTMLUtilities.bold("Author:") + HTML_SPACE +
HTMLUtilities.friendlyEncodeHTML(toToolTip(author)); HTMLUtilities.escapeHTML(toToolTip(author));
String htmlCategory = String htmlCategory = HTMLUtilities.bold("Category:") + HTML_SPACE +
HTMLUtilities.bold("Category:") + HTML_SPACE + HTMLUtilities.friendlyEncodeHTML( HTMLUtilities.escapeHTML(toToolTip(StringUtilities.convertStringArray(category, ".")));
toToolTip(StringUtilities.convertStringArray(category, ".")));
String htmlKeyBinding = String htmlKeyBinding =
HTMLUtilities.bold("Key Binding:") + HTML_SPACE + getKeybindingToolTip(); HTMLUtilities.bold("Key Binding:") + HTML_SPACE + getKeybindingToolTip();
String htmlMenuPath = String htmlMenuPath = HTMLUtilities.bold("Menu Path:") + HTML_SPACE +
HTMLUtilities.bold("Menu Path:") + HTML_SPACE + HTMLUtilities.friendlyEncodeHTML( HTMLUtilities.escapeHTML(toToolTip(StringUtilities.convertStringArray(menupath, ".")));
toToolTip(StringUtilities.convertStringArray(menupath, ".")));
StringBuilder buffer = new StringBuilder(); StringBuilder buffer = new StringBuilder();
buffer.append("<h3>").append(HTML_SPACE).append( buffer.append("<h3>").append(HTML_SPACE).append(HTMLUtilities.escapeHTML(getName())).append(
HTMLUtilities.friendlyEncodeHTML(getName())).append("</h3>"); "</h3>");
buffer.append(HTML_NEW_LINE); buffer.append(HTML_NEW_LINE);
buffer.append(HTML_SPACE).append(htmlDescription); buffer.append(HTML_SPACE).append(htmlDescription);
buffer.append(HTML_NEW_LINE); buffer.append(HTML_NEW_LINE);
@@ -314,7 +314,7 @@ public class CParserUtils {
// -remove newlines because the line wrapping utility always breaks on those // -remove newlines because the line wrapping utility always breaks on those
parseMessage = errorMessage.replaceAll("\n", " "); parseMessage = errorMessage.replaceAll("\n", " ");
parseMessage = HTMLUtilities.lineWrapWithHTMLLineBreaks( parseMessage = HTMLUtilities.lineWrapWithHTMLLineBreaks(
HTMLUtilities.friendlyEncodeHTML(parseMessage), 80); HTMLUtilities.escapeHTML(parseMessage), 80);
parseMessage = "<br><br>" + parseMessage + "<br>"; parseMessage = "<br><br>" + parseMessage + "<br>";
} }
@@ -71,7 +71,7 @@ public class DefaultDataTypeHTMLRepresentation extends HTMLDataTypeRepresentatio
StringBuilder buffer = new StringBuilder(); StringBuilder buffer = new StringBuilder();
String headerText = header.getText(); String headerText = header.getText();
String encodedHeaderText = HTMLUtilities.friendlyEncodeHTML(headerText); String encodedHeaderText = HTMLUtilities.escapeHTML(headerText);
headerText = wrapStringInColor(encodedHeaderText, header.getTextColor()); headerText = wrapStringInColor(encodedHeaderText, header.getTextColor());
buffer.append(headerText); buffer.append(headerText);
@@ -135,7 +135,7 @@ public abstract class HTMLDataTypeRepresentation {
if (comment == null) { if (comment == null) {
comment = dataType.getDescription(); comment = dataType.getDescription();
} }
return comment == null ? "" : HTMLUtilities.friendlyEncodeHTML(comment); return comment == null ? "" : HTMLUtilities.escapeHTML(comment);
} }
protected static String truncateAsNecessary(String string) { protected static String truncateAsNecessary(String string) {
@@ -327,7 +327,7 @@ public abstract class HTMLDataTypeRepresentation {
// put the path info in // put the path info in
CategoryPath path = dataType.getCategoryPath(); CategoryPath path = dataType.getCategoryPath();
headerLines.add(new TextLine(HTMLUtilities.friendlyEncodeHTML(path.getPath()))); headerLines.add(new TextLine(HTMLUtilities.escapeHTML(path.getPath())));
headerLines.add(new TextLine(BR)); headerLines.add(new TextLine(BR));
return headerLines; return headerLines;
@@ -29,7 +29,7 @@ public class MissingArchiveDataTypeHTMLRepresentation extends HTMLDataTypeRepres
return "<i>Could not find data type archive</i>"; return "<i>Could not find data type archive</i>";
} }
return "<i>Could not access data type archive: " + return "<i>Could not access data type archive: " +
HTMLUtilities.friendlyEncodeHTML(sourceArchive.getName()) + "</i>"; HTMLUtilities.escapeHTML(sourceArchive.getName()) + "</i>";
} }
@Override @Override
@@ -253,7 +253,7 @@ public class OpenProgramTask extends Task {
SystemUtilities.runSwingNow(() -> { SystemUtilities.runSwingNow(() -> {
int option = OptionDialog.showYesNoDialog(null, "Crash Recovery Data Found", int option = OptionDialog.showYesNoDialog(null, "Crash Recovery Data Found",
"<html>" + HTMLUtilities.friendlyEncodeHTML(filename) + " has crash data.<br>" + "<html>" + HTMLUtilities.escapeHTML(filename) + " has crash data.<br>" +
"Would you like to recover unsaved changes?"); "Would you like to recover unsaved changes?");
result.set(option == OptionDialog.OPTION_ONE); result.set(option == OptionDialog.OPTION_ONE);
}); });
@@ -43,14 +43,14 @@ public class HorizontalRuleAction extends DockingAction {
// '&' of the replacement html entity (like '&lt;') will be consumed by the menudata deity // '&' of the replacement html entity (like '&lt;') will be consumed by the menudata deity
// and lost forever. // and lost forever.
setMenuBarData(new MenuData(new String[] { setMenuBarData(new MenuData(new String[] {
"<HTML><CENTER><FONT SIZE=2 COLOR=SILVER>" + HTMLUtilities.friendlyEncodeHTML(topName) + "<HTML><CENTER><FONT SIZE=2 COLOR=SILVER>" + HTMLUtilities.escapeHTML(topName) +
"<BR>" + HTMLUtilities.friendlyEncodeHTML(bottomName) + "</FONT></CENTER>" })); "<BR>" + HTMLUtilities.escapeHTML(bottomName) + "</FONT></CENTER>" }));
// 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 = "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"; String padding = "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
setDescription("<HTML><CENTER><B>" + padding + HTMLUtilities.friendlyEncodeHTML(topName) + setDescription("<HTML><CENTER><B>" + padding + HTMLUtilities.escapeHTML(topName) + padding +
padding + "<B><HR><B>" + padding + HTMLUtilities.friendlyEncodeHTML(bottomName) + "<B><HR><B>" + padding + HTMLUtilities.escapeHTML(bottomName) + padding +
padding + "</B></CENTER>"); "</B></CENTER>");
} }
@Override @Override
@@ -176,7 +176,7 @@ class DiffActionManager {
openCloseProgram2Action.setDescription( openCloseProgram2Action.setDescription(
"<html><center>Close Diff View</center><br>" + "<html><center>Close Diff View</center><br>" +
"Current diff: " + "Current diff: " +
"<b>"+HTMLUtilities.friendlyEncodeHTML(firstName)+"</b> to <b>" +HTMLUtilities.friendlyEncodeHTML(secondName)+"</b>"); "<b>"+HTMLUtilities.escapeHTML(firstName)+"</b> to <b>" +HTMLUtilities.escapeHTML(secondName)+"</b>");
//@formatter:on //@formatter:on
} }
@@ -119,10 +119,9 @@ public class ApplyBlockedMatchAction extends DockingAction {
private String getAssociationDisplayString(VTAssociation association) { private String getAssociationDisplayString(VTAssociation association) {
return association.getType().toString() + " match with source of <b>" + return association.getType().toString() + " match with source of <b>" +
HTMLUtilities.friendlyEncodeHTML(association.getSourceAddress().toString()) + HTMLUtilities.escapeHTML(association.getSourceAddress().toString()) +
"</b> and destination of <b>" + "</b> and destination of <b>" +
HTMLUtilities.friendlyEncodeHTML(association.getDestinationAddress().toString()) + HTMLUtilities.escapeHTML(association.getDestinationAddress().toString()) + "</b>";
"</b>";
} }
@Override @Override
@@ -99,8 +99,8 @@ public class SummaryPanel extends AbstractMageJPanel<VTWizardStateKey> {
// source program // source program
label.append("Source Program:"); label.append("Source Program:");
summary.append(sourceProgramName == null ? "(null)" summary.append(
: HTMLUtilities.friendlyEncodeHTML(sourceProgramName)); sourceProgramName == null ? "(null)" : HTMLUtilities.escapeHTML(sourceProgramName));
label.append("<br>"); label.append("<br>");
summary.append("<br>"); summary.append("<br>");
@@ -108,7 +108,7 @@ public class SummaryPanel extends AbstractMageJPanel<VTWizardStateKey> {
label.append("Destination Program:"); label.append("Destination Program:");
summary.append(destinationProgramName == null ? "(null)" summary.append(destinationProgramName == null ? "(null)"
: HTMLUtilities.friendlyEncodeHTML(destinationProgramName)); : HTMLUtilities.escapeHTML(destinationProgramName));
label.append("<br>"); label.append("<br>");
summary.append("<br>"); summary.append("<br>");
@@ -82,7 +82,7 @@ public class VTWizardUtils {
String filename = domainFile.getName(); String filename = domainFile.getName();
int result = OptionDialog.showYesNoDialog(parent, "Save Version Tracking Changes?", int result = OptionDialog.showYesNoDialog(parent, "Save Version Tracking Changes?",
"<html>Unsaved Version Tracking changes found for session: " + "<html>Unsaved Version Tracking changes found for session: " +
HTMLUtilities.friendlyEncodeHTML(filename) + ". <br>" + HTMLUtilities.escapeHTML(filename) + ". <br>" +
"Would you like to save these changes?"); "Would you like to save these changes?");
boolean doSave = result == OptionDialog.YES_OPTION; boolean doSave = result == OptionDialog.YES_OPTION;
@@ -100,7 +100,7 @@ public class VTWizardUtils {
String filename = domainFile.getName(); String filename = domainFile.getName();
int result = OptionDialog.showYesNoCancelDialog(parent, "Save Version Tracking Changes?", int result = OptionDialog.showYesNoCancelDialog(parent, "Save Version Tracking Changes?",
"<html>Unsaved Version Tracking changes found for session: " + "<html>Unsaved Version Tracking changes found for session: " +
HTMLUtilities.friendlyEncodeHTML(filename) + ". <br>" + HTMLUtilities.escapeHTML(filename) + ". <br>" +
"Would you like to save these changes?"); "Would you like to save these changes?");
if (result == OptionDialog.CANCEL_OPTION) { if (result == OptionDialog.CANCEL_OPTION) {
@@ -138,7 +138,7 @@ public class OptionsPanel extends JPanel {
Options currentOptions = getSelectedOptions(); Options currentOptions = getSelectedOptions();
int userChoice = OptionDialog.showOptionDialog(viewPanel, "Restore Defaults?", int userChoice = OptionDialog.showOptionDialog(viewPanel, "Restore Defaults?",
"<html>Restore <b>" + HTMLUtilities.friendlyEncodeHTML(currentOptions.getName()) + "<html>Restore <b>" + HTMLUtilities.escapeHTML(currentOptions.getName()) +
"</b> to default option values <b>and erase current settings?</b>", "</b> to default option values <b>and erase current settings?</b>",
"Restore Defaults"); "Restore Defaults");
if (userChoice == OptionDialog.CANCEL_OPTION) { if (userChoice == OptionDialog.CANCEL_OPTION) {
@@ -127,7 +127,7 @@ public class FileDropDownSelectionDataModel implements DropDownTextFieldDataMode
public String getDescription(File file) { public String getDescription(File file) {
boolean isDir = file.isDirectory(); boolean isDir = file.isDirectory();
return "<html><table>" + "<tr><td>" + (isDir ? "Directory: " : "File: ") + "</td><td>" + return "<html><table>" + "<tr><td>" + (isDir ? "Directory: " : "File: ") + "</td><td>" +
"<b>" + HTMLUtilities.friendlyEncodeHTML(file.getName()) + "</b>" + "</td></tr>" + "<b>" + HTMLUtilities.escapeHTML(file.getName()) + "</b>" + "</td></tr>" +
"<tr><td>Size:</td><td>" + (isDir ? "0" : file.length()) + " bytes" + "</td></tr>" + "<tr><td>Size:</td><td>" + (isDir ? "0" : file.length()) + " bytes" + "</td></tr>" +
"<tr><td>Last modified:</td><td>" + "<tr><td>Last modified:</td><td>" +
GhidraFileChooser.format.format(new Date(file.lastModified())) + "</td></tr>" + GhidraFileChooser.format.format(new Date(file.lastModified())) + "</td></tr>" +

Some files were not shown because too many files have changed in this diff Show More