mirror of
https://github.com/discourse/discourse.git
synced 2024-11-26 11:03:40 +08:00
Include /^http... prefix in onebox whitelist URLs regexes to prevent XSS.
This commit is contained in:
parent
ea9196a8a2
commit
a7a2dcebac
|
@ -3,7 +3,7 @@ require_dependency 'oneboxer/oembed_onebox'
|
||||||
module Oneboxer
|
module Oneboxer
|
||||||
class ClikthroughOnebox < OembedOnebox
|
class ClikthroughOnebox < OembedOnebox
|
||||||
|
|
||||||
matcher /clikthrough\.com\/theater\/video\/\d+$/
|
matcher /^https?:\/\/(?:www\.)?clikthrough\.com\/theater\/video\/\d+$/
|
||||||
|
|
||||||
def oembed_endpoint
|
def oembed_endpoint
|
||||||
"http://clikthrough.com/services/oembed?url=#{BaseOnebox.uriencode(@url)}"
|
"http://clikthrough.com/services/oembed?url=#{BaseOnebox.uriencode(@url)}"
|
||||||
|
|
|
@ -3,7 +3,7 @@ require_dependency 'oneboxer/oembed_onebox'
|
||||||
module Oneboxer
|
module Oneboxer
|
||||||
class DailymotionOnebox < OembedOnebox
|
class DailymotionOnebox < OembedOnebox
|
||||||
|
|
||||||
matcher /dailymotion\.com\/.+$/
|
matcher /^https?:\/\/(?:www\.)?dailymotion\.com\/.+$/
|
||||||
|
|
||||||
def oembed_endpoint
|
def oembed_endpoint
|
||||||
"http://www.dailymotion.com/api/oembed/?url=#{BaseOnebox.uriencode(@url)}"
|
"http://www.dailymotion.com/api/oembed/?url=#{BaseOnebox.uriencode(@url)}"
|
||||||
|
|
|
@ -3,7 +3,7 @@ require_dependency 'oneboxer/oembed_onebox'
|
||||||
module Oneboxer
|
module Oneboxer
|
||||||
class DotsubOnebox < OembedOnebox
|
class DotsubOnebox < OembedOnebox
|
||||||
|
|
||||||
matcher /dotsub\.com\/.+$/
|
matcher /^https?:\/\/(?:www\.)?dotsub\.com\/.+$/
|
||||||
|
|
||||||
def oembed_endpoint
|
def oembed_endpoint
|
||||||
"http://dotsub.com/services/oembed?url=#{BaseOnebox.uriencode(@url)}"
|
"http://dotsub.com/services/oembed?url=#{BaseOnebox.uriencode(@url)}"
|
||||||
|
|
|
@ -3,7 +3,7 @@ require_dependency 'oneboxer/handlebars_onebox'
|
||||||
module Oneboxer
|
module Oneboxer
|
||||||
class GithubBlobOnebox < HandlebarsOnebox
|
class GithubBlobOnebox < HandlebarsOnebox
|
||||||
|
|
||||||
matcher /github\.com\/[^\/]+\/[^\/]+\/blob\/.*/
|
matcher /^https?:\/\/(?:www\.)?github\.com\/[^\/]+\/[^\/]+\/blob\/.*/
|
||||||
favicon 'github.png'
|
favicon 'github.png'
|
||||||
|
|
||||||
def translate_url
|
def translate_url
|
||||||
|
|
|
@ -3,7 +3,7 @@ require_dependency 'oneboxer/oembed_onebox'
|
||||||
module Oneboxer
|
module Oneboxer
|
||||||
class KinomapOnebox < OembedOnebox
|
class KinomapOnebox < OembedOnebox
|
||||||
|
|
||||||
matcher /kinomap\.com/
|
matcher /^https?:\/\/(?:www\.)?kinomap\.com/
|
||||||
|
|
||||||
def oembed_endpoint
|
def oembed_endpoint
|
||||||
"http://www.kinomap.com/oembed?url=#{BaseOnebox.uriencode(@url)}&format=json"
|
"http://www.kinomap.com/oembed?url=#{BaseOnebox.uriencode(@url)}&format=json"
|
||||||
|
|
|
@ -3,7 +3,7 @@ require_dependency 'oneboxer/oembed_onebox'
|
||||||
module Oneboxer
|
module Oneboxer
|
||||||
class NfbOnebox < OembedOnebox
|
class NfbOnebox < OembedOnebox
|
||||||
|
|
||||||
matcher /nfb\.ca\/film\/[-\w]+\/?/
|
matcher /^https?:\/\/(?:www\.)?nfb\.ca\/film\/[-\w]+\/?/
|
||||||
|
|
||||||
def oembed_endpoint
|
def oembed_endpoint
|
||||||
"http://www.nfb.ca/remote/services/oembed/?url=#{BaseOnebox.uriencode(@url)}&format=json"
|
"http://www.nfb.ca/remote/services/oembed/?url=#{BaseOnebox.uriencode(@url)}&format=json"
|
||||||
|
|
|
@ -3,7 +3,7 @@ require_dependency 'oneboxer/oembed_onebox'
|
||||||
module Oneboxer
|
module Oneboxer
|
||||||
class ViddlerOnebox < OembedOnebox
|
class ViddlerOnebox < OembedOnebox
|
||||||
|
|
||||||
matcher /viddler\.com\/.+$/
|
matcher /^https?:\/\/(?:www\.)?viddler\.com\/.+$/
|
||||||
|
|
||||||
def oembed_endpoint
|
def oembed_endpoint
|
||||||
"http://lab.viddler.com/services/oembed/?url=#{BaseOnebox.uriencode(@url)}"
|
"http://lab.viddler.com/services/oembed/?url=#{BaseOnebox.uriencode(@url)}"
|
||||||
|
|
|
@ -2,77 +2,77 @@ module Oneboxer
|
||||||
|
|
||||||
module Whitelist
|
module Whitelist
|
||||||
def self.entries
|
def self.entries
|
||||||
[/cnn\.com\/.+/,
|
[/^https?:\/\/(?:www\.)?cnn\.com\/.+/,
|
||||||
/washingtonpost\.com\/.+/,
|
/^https?:\/\/(?:www\.)?washingtonpost\.com\/.+/,
|
||||||
/\/\d{4}\/\d{2}\/\d{2}\//, # wordpress
|
/^https?:\/\/(?:www\.)?\/\d{4}\/\d{2}\/\d{2}\//, # wordpress
|
||||||
/funnyordie\.com\/.+/,
|
/^https?:\/\/(?:www\.)?funnyordie\.com\/.+/,
|
||||||
/youtube\.com\/.+/,
|
/^https?:\/\/(?:www\.)?youtube\.com\/.+/,
|
||||||
/youtu\.be\/.+/,
|
/^https?:\/\/(?:www\.)?youtu\.be\/.+/,
|
||||||
/500px\.com\/.+/,
|
/^https?:\/\/(?:www\.)?500px\.com\/.+/,
|
||||||
/scribd\.com\/.+/,
|
/^https?:\/\/(?:www\.)?scribd\.com\/.+/,
|
||||||
/photobucket\.com\/.+/,
|
/^https?:\/\/(?:www\.)?photobucket\.com\/.+/,
|
||||||
/ebay\.(com|ca|co\.uk)\/.+/,
|
/^https?:\/\/(?:www\.)?ebay\.(com|ca|co\.uk)\/.+/,
|
||||||
/nytimes\.com\/.+/,
|
/^https?:\/\/(?:www\.)?nytimes\.com\/.+/,
|
||||||
/tumblr\.com\/.+/,
|
/^https?:\/\/(?:www\.)?tumblr\.com\/.+/,
|
||||||
/pinterest\.com\/.+/,
|
/^https?:\/\/(?:www\.)?pinterest\.com\/.+/,
|
||||||
/imdb\.com\/.+/,
|
/^https?:\/\/(?:www\.)?imdb\.com\/.+/,
|
||||||
/bbc\.co\.uk\/.+/,
|
/^https?:\/\/(?:www\.)?bbc\.co\.uk\/.+/,
|
||||||
/ask\.com\/.+/,
|
/^https?:\/\/(?:www\.)?ask\.com\/.+/,
|
||||||
/huffingtonpost\.com\/.+/,
|
/^https?:\/\/(?:www\.)?huffingtonpost\.com\/.+/,
|
||||||
/aol\.(com|ca)\/.+/,
|
/^https?:\/\/(?:www\.)?aol\.(com|ca)\/.+/,
|
||||||
/espn\.go\.com\/.+/,
|
/^https?:\/\/(?:www\.)?espn\.go\.com\/.+/,
|
||||||
/about\.com\/.+/,
|
/^https?:\/\/(?:www\.)?about\.com\/.+/,
|
||||||
/cnet\.com\/.+/,
|
/^https?:\/\/(?:www\.)?cnet\.com\/.+/,
|
||||||
/ehow\.com\/.+/,
|
/^https?:\/\/(?:www\.)?ehow\.com\/.+/,
|
||||||
/dailymail\.co\.uk\/.+/,
|
/^https?:\/\/(?:www\.)?dailymail\.co\.uk\/.+/,
|
||||||
/indiatimes\.com\/.+/,
|
/^https?:\/\/(?:www\.)?indiatimes\.com\/.+/,
|
||||||
/answers\.com\/.+/,
|
/^https?:\/\/(?:www\.)?answers\.com\/.+/,
|
||||||
/instagr\.am\/.+/,
|
/^https?:\/\/(?:www\.)?instagr\.am\/.+/,
|
||||||
/battle\.net\/.+/,
|
/^https?:\/\/(?:www\.)?battle\.net\/.+/,
|
||||||
/sourceforge\.net\/.+/,
|
/^https?:\/\/(?:www\.)?sourceforge\.net\/.+/,
|
||||||
/myspace\.com\/.+/,
|
/^https?:\/\/(?:www\.)?myspace\.com\/.+/,
|
||||||
/wikia\.com\/.+/,
|
/^https?:\/\/(?:www\.)?wikia\.com\/.+/,
|
||||||
/etsy\.com\/.+/,
|
/^https?:\/\/(?:www\.)?etsy\.com\/.+/,
|
||||||
/walmart\.com\/.+/,
|
/^https?:\/\/(?:www\.)?walmart\.com\/.+/,
|
||||||
/reference\.com\/.+/,
|
/^https?:\/\/(?:www\.)?reference\.com\/.+/,
|
||||||
/yelp\.com\/.+/,
|
/^https?:\/\/(?:www\.)?yelp\.com\/.+/,
|
||||||
/foxnews\.com\/.+/,
|
/^https?:\/\/(?:www\.)?foxnews\.com\/.+/,
|
||||||
/guardian\.co\.uk\/.+/,
|
/^https?:\/\/(?:www\.)?guardian\.co\.uk\/.+/,
|
||||||
/digg\.com\/.+/,
|
/^https?:\/\/(?:www\.)?digg\.com\/.+/,
|
||||||
/squidoo\.com\/.+/,
|
/^https?:\/\/(?:www\.)?squidoo\.com\/.+/,
|
||||||
/wsj\.com\/.+/,
|
/^https?:\/\/(?:www\.)?wsj\.com\/.+/,
|
||||||
/archive\.org\/.+/,
|
/^https?:\/\/(?:www\.)?archive\.org\/.+/,
|
||||||
/nba\.com\/.+/,
|
/^https?:\/\/(?:www\.)?nba\.com\/.+/,
|
||||||
/samsung\.com\/.+/,
|
/^https?:\/\/(?:www\.)?samsung\.com\/.+/,
|
||||||
/mashable\.com\/.+/,
|
/^https?:\/\/(?:www\.)?mashable\.com\/.+/,
|
||||||
/forbes\.com\/.+/,
|
/^https?:\/\/(?:www\.)?forbes\.com\/.+/,
|
||||||
/soundcloud\.com\/.+/,
|
/^https?:\/\/(?:www\.)?soundcloud\.com\/.+/,
|
||||||
/thefreedictionary\.com\/.+/,
|
/^https?:\/\/(?:www\.)?thefreedictionary\.com\/.+/,
|
||||||
/groupon\.com\/.+/,
|
/^https?:\/\/(?:www\.)?groupon\.com\/.+/,
|
||||||
/ikea\.com\/.+/,
|
/^https?:\/\/(?:www\.)?ikea\.com\/.+/,
|
||||||
/dell\.com\/.+/,
|
/^https?:\/\/(?:www\.)?dell\.com\/.+/,
|
||||||
/mlb\.com\/.+/,
|
/^https?:\/\/(?:www\.)?mlb\.com\/.+/,
|
||||||
/bestbuy\.(com|ca)\/.+/,
|
/^https?:\/\/(?:www\.)?bestbuy\.(com|ca)\/.+/,
|
||||||
/bloomberg\.com\/.+/,
|
/^https?:\/\/(?:www\.)?bloomberg\.com\/.+/,
|
||||||
/ign\.com\/.+/,
|
/^https?:\/\/(?:www\.)?ign\.com\/.+/,
|
||||||
/twitpic\.com\/.+/,
|
/^https?:\/\/(?:www\.)?twitpic\.com\/.+/,
|
||||||
/techcrunch\.com\/.+/,
|
/^https?:\/\/(?:www\.)?techcrunch\.com\/.+/,
|
||||||
/usatoday\.com\/.+/,
|
/^https?:\/\/(?:www\.)?usatoday\.com\/.+/,
|
||||||
/go\.com\/.+/,
|
/^https?:\/\/(?:www\.)?go\.com\/.+/,
|
||||||
/businessinsider\.com\/.+/,
|
/^https?:\/\/(?:www\.)?businessinsider\.com\/.+/,
|
||||||
/zillow\.com\/.+/,
|
/^https?:\/\/(?:www\.)?zillow\.com\/.+/,
|
||||||
/tmz\.com\/.+/,
|
/^https?:\/\/(?:www\.)?tmz\.com\/.+/,
|
||||||
/thesun\.co\.uk\/.+/,
|
/^https?:\/\/(?:www\.)?thesun\.co\.uk\/.+/,
|
||||||
/thestar\.(com|ca)\/.+/,
|
/^https?:\/\/(?:www\.)?thestar\.(com|ca)\/.+/,
|
||||||
/theglobeandmail\.com\/.+/,
|
/^https?:\/\/(?:www\.)?theglobeandmail\.com\/.+/,
|
||||||
/torontosun\.com\/.+/,
|
/^https?:\/\/(?:www\.)?torontosun\.com\/.+/,
|
||||||
/kickstarter\.com\/.+/,
|
/^https?:\/\/(?:www\.)?kickstarter\.com\/.+/,
|
||||||
/wired\.com\/.+/,
|
/^https?:\/\/(?:www\.)?wired\.com\/.+/,
|
||||||
/time\.com\/.+/,
|
/^https?:\/\/(?:www\.)?time\.com\/.+/,
|
||||||
/npr\.org\/.+/,
|
/^https?:\/\/(?:www\.)?npr\.org\/.+/,
|
||||||
/cracked\.com\/.+/,
|
/^https?:\/\/(?:www\.)?cracked\.com\/.+/,
|
||||||
/thinkgeek\.com\/.+/,
|
/^https?:\/\/(?:www\.)?thinkgeek\.com\/.+/,
|
||||||
/deadline\.com\/.+/
|
/^https?:\/\/(?:www\.)?deadline\.com\/.+/
|
||||||
]
|
]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,7 @@ require_dependency 'oneboxer/oembed_onebox'
|
||||||
module Oneboxer
|
module Oneboxer
|
||||||
class YfrogOnebox < OembedOnebox
|
class YfrogOnebox < OembedOnebox
|
||||||
|
|
||||||
matcher /yfrog\.(com|ru|com\.tr|it|fr|co\.il|co\.uk|com\.pl|pl|eu|us)\/[a-zA-Z0-9]+/
|
matcher /^https?:\/\/(?:www\.)?yfrog\.(com|ru|com\.tr|it|fr|co\.il|co\.uk|com\.pl|pl|eu|us)\/[a-zA-Z0-9]+/
|
||||||
|
|
||||||
def oembed_endpoint
|
def oembed_endpoint
|
||||||
"http://www.yfrog.com/api/oembed/?url=#{BaseOnebox.uriencode(@url)}&format=json"
|
"http://www.yfrog.com/api/oembed/?url=#{BaseOnebox.uriencode(@url)}&format=json"
|
||||||
|
|
Loading…
Reference in New Issue
Block a user