Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TxUtils: use regex to check for valid domain #4243

Merged
merged 1 commit into from
Jan 18, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions js/TxUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,14 @@ function checkSignature(signature) {
}

function isValidOpenAliasAddress(address) {
address = address.trim()
// we can get an awful lot of valid domains, including non ASCII chars... accept anything
// there should be something after the .
// make sure it is not some kind of floating number
return address.length > 2 && isNaN(parseFloat(address)) && address.indexOf('.') >= 0
var regex = /^[A-Za-z0-9-]+(\.[A-Za-z0-9-]+)+$/; // Basic domain structure

if (!regex.test(address)) {
return false;
}

const lastPart = address.substring(address.lastIndexOf('.') + 1);
return isNaN(parseInt(lastPart)) || lastPart !== parseInt(lastPart).toString();
}

function handleOpenAliasResolution(address, descriptionText) {
Expand Down
Loading