From 8aa7913aa6930b2aea643608c254d1a982ad013b Mon Sep 17 00:00:00 2001 From: Sudo-Ivan Date: Thu, 1 Jan 2026 17:35:14 -0600 Subject: [PATCH] feat(conversation): add validation for destination hash in ping functionality to ensure correct format and existence --- .../messages/ConversationDropDownMenu.vue | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/meshchatx/src/frontend/components/messages/ConversationDropDownMenu.vue b/meshchatx/src/frontend/components/messages/ConversationDropDownMenu.vue index ccf7f33..0534e5f 100644 --- a/meshchatx/src/frontend/components/messages/ConversationDropDownMenu.vue +++ b/meshchatx/src/frontend/components/messages/ConversationDropDownMenu.vue @@ -168,9 +168,20 @@ export default { } }, async onPingDestination() { + if (!this.peer || !this.peer.destination_hash) { + DialogUtils.alert("Invalid destination hash"); + return; + } + + const destinationHash = this.peer.destination_hash; + if (destinationHash.length !== 32 || !/^[0-9a-fA-F]+$/.test(destinationHash)) { + DialogUtils.alert("Invalid destination hash format"); + return; + } + try { // ping destination - const response = await window.axios.get(`/api/v1/ping/${this.peer.destination_hash}/lxmf.delivery`, { + const response = await window.axios.get(`/api/v1/ping/${destinationHash}/lxmf.delivery`, { params: { timeout: 30, }, @@ -181,7 +192,7 @@ export default { const rttDurationString = `${rttMilliseconds} ms`; const info = [ - `Valid reply from ${this.peer.destination_hash}`, + `Valid reply from ${destinationHash}`, `Duration: ${rttDurationString}`, `Hops There: ${pingResult.hops_there}`, `Hops Back: ${pingResult.hops_back}`,