Skip to content

Commit 1755c04

Browse files
committed
Qt/RPCConsole: Truncate filtered commands to just the command name, rather than skip it entirely in history
1 parent d80a006 commit 1755c04

File tree

1 file changed

+14
-16
lines changed

1 file changed

+14
-16
lines changed

src/qt/rpcconsole.cpp

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -74,14 +74,14 @@ const QStringList historyFilter = QStringList()
7474
<< "walletpassphrasechange"
7575
<< "encryptwallet";
7676

77-
bool command_may_contain_sensitive_data(const QString cmd)
77+
QString command_filter_sensitive_data(const QString cmd)
7878
{
7979
Q_FOREACH(QString unallowedCmd, historyFilter) {
8080
if (cmd.trimmed().startsWith(unallowedCmd)) {
81-
return true;
81+
return unallowedCmd;
8282
}
8383
}
84-
return false;
84+
return cmd;
8585
}
8686

8787
}
@@ -779,20 +779,18 @@ void RPCConsole::on_lineEdit_returnPressed()
779779
message(CMD_REQUEST, cmd);
780780
Q_EMIT cmdRequest(cmd);
781781

782-
bool storeHistory = !command_may_contain_sensitive_data(cmd);
782+
cmd = command_filter_sensitive_data(cmd);
783+
784+
// Remove command, if already in history
785+
history.removeOne(cmd);
786+
// Append command to history
787+
history.append(cmd);
788+
// Enforce maximum history size
789+
while(history.size() > CONSOLE_HISTORY)
790+
history.removeFirst();
791+
// Set pointer to end of history
792+
historyPtr = history.size();
783793

784-
if (storeHistory)
785-
{
786-
// Remove command, if already in history
787-
history.removeOne(cmd);
788-
// Append command to history
789-
history.append(cmd);
790-
// Enforce maximum history size
791-
while(history.size() > CONSOLE_HISTORY)
792-
history.removeFirst();
793-
// Set pointer to end of history
794-
historyPtr = history.size();
795-
}
796794
// Scroll console view to end
797795
scrollToEnd();
798796
}

0 commit comments

Comments
 (0)