Sanitize node pubkey search

This commit is contained in:
softsimon 2023-06-16 23:42:57 +02:00
parent 6c1cc89276
commit 13ca7d9025

View File

@ -373,7 +373,7 @@ class NodesApi {
public async $searchNodeByPublicKeyOrAlias(search: string) { public async $searchNodeByPublicKeyOrAlias(search: string) {
try { try {
const publicKeySearch = search.replace('%', '') + '%'; const publicKeySearch = search.replace(/[^a-zA-Z0-9]/g, '') + '%';
const aliasSearch = search const aliasSearch = search
.replace(/[-_.]/g, ' ') // Replace all -_. characters with empty space. Eg: "ln.nicehash" becomes "ln nicehash". .replace(/[-_.]/g, ' ') // Replace all -_. characters with empty space. Eg: "ln.nicehash" becomes "ln nicehash".
.replace(/[^a-zA-Z0-9 ]/g, '') // Remove all special characters and keep just A to Z, 0 to 9. .replace(/[^a-zA-Z0-9 ]/g, '') // Remove all special characters and keep just A to Z, 0 to 9.