| OLD | NEW | 
|---|
| 1 # This file is part of the Adblock Plus web scripts, | 1 # This file is part of the Adblock Plus web scripts, | 
| 2 # Copyright (C) 2006-present eyeo GmbH | 2 # Copyright (C) 2006-present eyeo GmbH | 
| 3 # | 3 # | 
| 4 # Adblock Plus is free software: you can redistribute it and/or modify | 4 # Adblock Plus is free software: you can redistribute it and/or modify | 
| 5 # it under the terms of the GNU General Public License version 3 as | 5 # it under the terms of the GNU General Public License version 3 as | 
| 6 # published by the Free Software Foundation. | 6 # published by the Free Software Foundation. | 
| 7 # | 7 # | 
| 8 # Adblock Plus is distributed in the hope that it will be useful, | 8 # Adblock Plus is distributed in the hope that it will be useful, | 
| 9 # but WITHOUT ANY WARRANTY; without even the implied warranty of | 9 # but WITHOUT ANY WARRANTY; without even the implied warranty of | 
| 10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | 10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | 
| (...skipping 10 matching lines...) Expand all  Loading... | 
| 21 from sitescripts.web import url_handler, request_path | 21 from sitescripts.web import url_handler, request_path | 
| 22 | 22 | 
| 23 | 23 | 
| 24 @url_handler('/sitekey-frame') | 24 @url_handler('/sitekey-frame') | 
| 25 def sitekey_frame(environ, start_response): | 25 def sitekey_frame(environ, start_response): | 
| 26     template_path, template_file = os.path.split( | 26     template_path, template_file = os.path.split( | 
| 27         get_config().get('testpages', 'sitekeyFrameTemplate'), | 27         get_config().get('testpages', 'sitekeyFrameTemplate'), | 
| 28     ) | 28     ) | 
| 29     template = get_template(template_file, template_path=template_path) | 29     template = get_template(template_file, template_path=template_path) | 
| 30 | 30 | 
|  | 31     http_path = request_path(environ) | 
|  | 32     http_host = environ['HTTP_HOST'] | 
|  | 33     http_ua = environ['HTTP_USER_AGENT'] | 
|  | 34 | 
| 31     key = M2Crypto.EVP.load_key(get_config().get('testpages', 'sitekeyPath')) | 35     key = M2Crypto.EVP.load_key(get_config().get('testpages', 'sitekeyPath')) | 
| 32     key.sign_init() | 36     key.sign_init() | 
| 33     key.sign_update('\x00'.join(( | 37     key.sign_update('\x00'.join([http_path, http_host, http_ua])) | 
| 34         request_path(environ), |  | 
| 35         environ['HTTP_HOST'], |  | 
| 36         environ['HTTP_USER_AGENT'], |  | 
| 37     ))) |  | 
| 38 |  | 
| 39     public_key = base64.b64encode(key.as_der()) | 38     public_key = base64.b64encode(key.as_der()) | 
| 40     signature = base64.b64encode(key.final()) | 39     signature = base64.b64encode(key.final()) | 
| 41 | 40 | 
| 42     start_response('200 OK', | 41     start_response('200 OK', [ | 
| 43                    [('Content-Type', 'text/html; charset=utf-8'), | 42         ('Content-Type', 'text/html; charset=utf-8'), | 
| 44                     ('X-Adblock-Key', '%s_%s' % (public_key, signature))]) | 43         ('X-Adblock-Key', '%s_%s' % (public_key, signature)), | 
| 45     return [template.render({'public_key': public_key, | 44     ]) | 
| 46                              'signature': signature}).encode('utf-8')] | 45     return [template.render({ | 
|  | 46         'public_key': public_key, | 
|  | 47         'signature': signature, | 
|  | 48         'http_path': http_path, | 
|  | 49         'http_host': http_host, | 
|  | 50         'http_ua': http_ua, | 
|  | 51     }).encode('utf-8')] | 
| OLD | NEW | 
|---|