mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2025-02-07 19:20:14 +00:00
GP-1754 - Updated Symbol Edit Dialog to not allow namespaces editing
with a blank name
This commit is contained in:
parent
026fad27ab
commit
2f278bd4ca
@ -153,6 +153,11 @@ public class AddEditDialog extends DialogComponentProvider {
|
||||
}
|
||||
|
||||
String symbolName = symbolPath.getName();
|
||||
if (StringUtils.isBlank(symbolName)) {
|
||||
// this is the case of having a namespace without a name, such as "Namespace::"
|
||||
setStatusText("Name cannot be blank while changing namespace");
|
||||
return;
|
||||
}
|
||||
|
||||
// see if the user specified a namespace path and if so, then get the
|
||||
// new namespace name from that path
|
||||
@ -178,6 +183,7 @@ public class AddEditDialog extends DialogComponentProvider {
|
||||
return;
|
||||
}
|
||||
|
||||
cmd = new CompoundCmd(symbol == null ? "Add Label" : "Edit Label");
|
||||
if (primaryCheckBox.isEnabled() && primaryCheckBox.isSelected()) {
|
||||
cmd.add(new SetLabelPrimaryCmd(addr, symbolName, parent));
|
||||
}
|
||||
|
@ -754,6 +754,32 @@ public class AddEditDialoglTest extends AbstractGhidraHeadedIntegrationTest {
|
||||
assertEquals(nsName, parentNs.getName());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSetNamespace_NamespaceWithoutFunctionName() throws Exception {
|
||||
|
||||
//
|
||||
// Test that we can cannot create a new namespace and clear a symbol name using this form:
|
||||
// "Namespace::"
|
||||
//
|
||||
// A blank name is a signal to reset to a default name, but we do not currently support
|
||||
// changing a namespace and resetting the name in the same operation.
|
||||
//
|
||||
|
||||
String functionName = "FUN_010065f0";
|
||||
Symbol functionSymbol = getSymbol(functionName);
|
||||
Namespace originalNamespace = functionSymbol.getParentNamespace();
|
||||
editLabel(functionSymbol);
|
||||
String nsName = "NewNamespace";
|
||||
setText(nsName + Namespace.DELIMITER);
|
||||
pressOk();
|
||||
assertTrue("Rename unsuccesful", dialog.isShowing());
|
||||
assertStatusText("Name cannot be blank while changing namespace");
|
||||
|
||||
Symbol newFunction = functionSymbol;
|
||||
Namespace parentNs = newFunction.getParentNamespace();
|
||||
assertSame(originalNamespace, parentNs);
|
||||
}
|
||||
|
||||
//==================================================================================================
|
||||
// Private Methods
|
||||
//==================================================================================================
|
||||
|
Loading…
Reference in New Issue
Block a user