mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06: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
@@ -9,9 +9,13 @@ module Onebox
|
||||
|
||||
MAX_FILES = 3
|
||||
|
||||
matches_regexp(%r{^http(?:s)?://gist\.(?:(?:\w)+\.)?(github)\.com(?:/)?})
|
||||
matches_domain("gist.github.com")
|
||||
always_https
|
||||
|
||||
def self.matches_path(path)
|
||||
path.match?(%r{^/[\w\-]+/[a-f0-9]+(/|$)})
|
||||
end
|
||||
|
||||
def url
|
||||
"https://api.github.com/gists/#{match[:sha]}"
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user