From: Paul Norman Date: Sat, 30 Aug 2014 08:32:35 +0000 (-0700) Subject: Add an imagery blacklist to capabilities X-Git-Tag: live~4325 X-Git-Url: https://git.openstreetmap.org/rails.git/commitdiff_plain/2d26d1f7644f0e1a4041339bad4c4570806fcac7?hp=ace4da4f8247997b1416c6ad8eaf41373d585c1d Add an imagery blacklist to capabilities This blacklist is for imagery which is of an incompatible license or ToS but is incorrectly used with some frequency. This adds a element to the capabilities XML which contains the blacklist information within it --- diff --git a/app/controllers/api_controller.rb b/app/controllers/api_controller.rb index 2c442c190..2f630c6d6 100644 --- a/app/controllers/api_controller.rb +++ b/app/controllers/api_controller.rb @@ -287,8 +287,16 @@ class ApiController < ApplicationController status['api'] = api_status.to_s status['gpx'] = gpx_status.to_s api << status - doc.root << api + policy = XML::Node.new 'policy' + blacklist = XML::Node.new 'imagery' + IMAGERY_BLACKLIST.each do |url_regex| + xnd = XML::Node.new 'blacklist' + xnd['regex'] = url_regex.to_s + blacklist << xnd + end + policy << blacklist + doc.root << policy render :text => doc.to_s, :content_type => "text/xml" end diff --git a/config/example.application.yml b/config/example.application.yml index d6a855ef5..3fbebdc76 100644 --- a/config/example.application.yml +++ b/config/example.application.yml @@ -84,6 +84,11 @@ defaults: &defaults require_terms_seen: false # Whether to require users to agree to the CTs before editing require_terms_agreed: false + # Imagery to return in capabilities as blacklisted + imagery_blacklist: + - ".*\\.googleapis\\.com/.*" + - ".*\\.google\\.com/.*" + - ".*\\.google\\.ru/.*" development: <<: *defaults