Skip to content

Commit fec82b6

Browse files
committed
fix: validate URL format before parsing in the parse function
1 parent cdb1eb4 commit fec82b6

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

Project/Sources/Classes/URL.4dm

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,14 @@ Function _init()
4040

4141
Function parse($inURL : Text)
4242

43+
This._init()
44+
45+
// Before parsing, check if the URL is empty or valid
46+
var $isValid : Boolean:=Match regex("^(https?|wss?):\\/\\/([^\\s\\/?#]+)([^\\s]*)$"; $inURL)
47+
If (Not($isValid))
48+
return
49+
End if
50+
4351
// Parse the URL into its components
4452
// Example: https://username:[email protected]:8080/path/to/resource?query=param#ref
4553
// Result:
@@ -54,8 +62,6 @@ Function parse($inURL : Text)
5462
// ref: ref
5563
// queryParams: [{name: "query"; value: "param"}]
5664

57-
This._init()
58-
5965
If (Length($inURL)>0)
6066

6167
// See: https://www.rfc-editor.org/rfc/rfc3986#appendix-B

0 commit comments

Comments
 (0)