Skip to content

A platform for community discussion. Free, open, simple.

SECURITY: Prevent ReDOS by making the SSH url regex unambiguous (#20000)

Bianca Nenciub32db6f2a333
diff --git a/lib/git_url.rb b/lib/git_url.rb
index d1980a94de7..f991d585c2c 100644
--- a/lib/git_url.rb
+++ b/lib/git_url.rb
@@ -2,7 +2,7 @@
module GitUrl
class << self
- SSH_REGEXP = /(\w+@(\w+\.)*\w+):(.*)/
+ SSH_REGEXP = /\A(\w+@\w+(\.\w+)*):(.*)\z/
def normalize(url)
if m = SSH_REGEXP.match(url)