mirror of
https://github.com/discourse/discourse.git
synced 2025-05-25 18:41:58 +08:00
SECURITY: Restrict allowed URL patterns
Restrict allowed URL patterns for oneboxes.
This commit is contained in:

committed by
Roman Rizzi

parent
17e1bfe069
commit
17116c440b
@ -12,9 +12,13 @@ module Onebox
|
||||
include Onebox::Mixins::GithubBody
|
||||
include Onebox::Mixins::GithubAuthHeader
|
||||
|
||||
matches_regexp(%r{^https?://(?:www\.)?(?:(?:\w)+\.)?(github)\.com(?:/)?(?:.)*/commit/})
|
||||
matches_domain("github.com", "www.github.com")
|
||||
always_https
|
||||
|
||||
def self.matches_path(path)
|
||||
path.match?(%r{^/[\w\-]+/[\w\-]+/commit/[a-f0-9]{40}$})
|
||||
end
|
||||
|
||||
def url
|
||||
"https://api.github.com/repos/#{match[:org]}/#{match[:repository]}/commits/#{match[:sha]}"
|
||||
end
|
||||
|
Reference in New Issue
Block a user