Skip to content

Commit

Permalink
add IBC port name validation
Browse files Browse the repository at this point in the history
  • Loading branch information
iomekam committed Apr 26, 2024
1 parent 252a503 commit 7e69bed
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions packages/network/src/network.js
Original file line number Diff line number Diff line change
Expand Up @@ -1451,6 +1451,15 @@ export const preparePortAllocator = (zone, { watch }) =>
let localAddr = `/ibc-port/${specifiedName}`;

if (specifiedName) {
// Contains at least two characters and only allows valid characters specified in IBC spec
const match = specifiedName.match(
new RegExp('^[a-zA-Z0-9.,_+\\-#<>\\[\\]]{2,128}$'),
);

if (!match) {
throw new Error(`Invalid IBC port name: ${specifiedName}`);
}

localAddr = `/ibc-port/custom-${specifiedName}`;
}

Expand All @@ -1472,6 +1481,15 @@ export const preparePortAllocator = (zone, { watch }) =>
let localAddr = `/local/${specifiedName}`;

if (specifiedName) {
// Contains at least two characters and only allows valid characters specified in IBC spec
const match = specifiedName.match(
new RegExp('^[a-zA-Z0-9.,_+\\-#<>\\[\\]]{2,128}$'),
);

if (!match) {
throw new Error(`Invalid IBC port name: ${specifiedName}`);
}

localAddr = `/local/custom-${specifiedName}`;
}

Expand Down

0 comments on commit 7e69bed

Please sign in to comment.