summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarin Jankovski <maxlazio@gmail.com>2015-07-17 15:26:09 +0200
committerMarin Jankovski <maxlazio@gmail.com>2015-07-17 15:26:09 +0200
commitc3e35917fbfbe64a068e387207aa510d76852e61 (patch)
tree8673256cd69c547396e4d5a8bf06747a1ddcda76
parentb351e6f50c2fdc0a8b1613c277d4272d92b22115 (diff)
downloadgitlab-ce-c3e35917fbfbe64a068e387207aa510d76852e61.tar.gz
Validate format of project_url and token for GitLab CI service.
-rw-r--r--app/models/project_services/gitlab_ci_service.rb8
1 files changed, 6 insertions, 2 deletions
diff --git a/app/models/project_services/gitlab_ci_service.rb b/app/models/project_services/gitlab_ci_service.rb
index c284e19fe50..5aaa4e85cbc 100644
--- a/app/models/project_services/gitlab_ci_service.rb
+++ b/app/models/project_services/gitlab_ci_service.rb
@@ -22,8 +22,12 @@ class GitlabCiService < CiService
API_PREFIX = "api/v1"
prop_accessor :project_url, :token
- validates :project_url, presence: true, if: :activated?
- validates :token, presence: true, if: :activated?
+ validates :project_url,
+ presence: true,
+ format: { with: /\A#{URI.regexp(%w(http https))}\z/, message: "should be a valid url" }, if: :activated?
+ validates :token,
+ presence: true,
+ format: { with: /\A([A-Za-z0-9]+)\z/ }, if: :activated?
after_save :compose_service_hook, if: :activated?