Skip to content

Commit

Permalink
fix: alter the regex in the isValidDomain function to accept hyphens (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
Julio A. authored Oct 16, 2024
1 parent 8bbe581 commit f810929
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/modern-trees-draw.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@rocket.chat/meteor': patch
---

Fixed the regex for domains in the isValidDomain function
2 changes: 1 addition & 1 deletion apps/meteor/app/lib/server/functions/checkUrlForSsrf.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export const isValidIPv4 = (ip: string): boolean => {
};

export const isValidDomain = (domain: string): boolean => {
const domainPattern = /^(?!-)(?!.*--)[A-Za-z0-9-]{1,63}(?<!-)\.?([A-Za-z]{2,63}\.?)*[A-Za-z]{2,63}$/;
const domainPattern = /^(?!-)(?!.*--)[A-Za-z0-9-]{1,63}(?<!-)\.?([A-Za-z0-9-]{2,63}\.?)*[A-Za-z]{2,63}$/;
if (!domainPattern.test(domain)) {
return false;
}
Expand Down

0 comments on commit f810929

Please sign in to comment.