From 64404a19024e9fe4defa35b2b8d7e63003a3184e Mon Sep 17 00:00:00 2001 From: IceArmy Date: Fri, 24 Jun 2011 18:19:54 -0700 Subject: [PATCH] Adding "--local-access-remote=[yes|no]". * This will allow local content to access remote content, bypassing the same origin policy. * It's controllable from the CLI and through the "page.settings" property * This addresses Issue #28 but only partially: it's still not possible to make _remote content access other remote content on a different origin_. --- python/pyphantomjs/phantom.py | 1 + python/pyphantomjs/pyphantomjs.py | 1 + python/pyphantomjs/utils.py | 4 ++++ python/pyphantomjs/webpage.py | 1 + 4 files changed, 7 insertions(+) diff --git a/python/pyphantomjs/phantom.py b/python/pyphantomjs/phantom.py index 4d24eb05..3f38b539 100644 --- a/python/pyphantomjs/phantom.py +++ b/python/pyphantomjs/phantom.py @@ -64,6 +64,7 @@ class Phantom(QObject): self.m_defaultPageSettings['loadImages'] = args.load_images self.m_defaultPageSettings['loadPlugins'] = args.load_plugins self.m_defaultPageSettings['userAgent'] = self.m_page.userAgent() + self.m_defaultPageSettings['localAccessRemote'] = args.local_access_remote self.m_page.applySettings(self.m_defaultPageSettings) self.libraryPath = os.path.dirname(os.path.abspath(self.m_scriptFile)) diff --git a/python/pyphantomjs/pyphantomjs.py b/python/pyphantomjs/pyphantomjs.py index 7a810cd4..8004f3a5 100644 --- a/python/pyphantomjs/pyphantomjs.py +++ b/python/pyphantomjs/pyphantomjs.py @@ -60,6 +60,7 @@ def parseArgs(args): args.ignore_ssl_errors = False if args.ignore_ssl_errors == 'no' else True args.load_images = True if args.load_images == 'yes' else False args.load_plugins = False if args.load_plugins == 'no' else True + args.local_access_remote = False if args.local_access_remote == 'no' else True if args.proxy: item = args.proxy.split(':') diff --git a/python/pyphantomjs/utils.py b/python/pyphantomjs/utils.py index efd540c5..60c03b76 100644 --- a/python/pyphantomjs/utils.py +++ b/python/pyphantomjs/utils.py @@ -79,6 +79,10 @@ def argParser(): choices=['yes', 'no'], help='Load all plugins (i.e. Flash, Silverlight, ...) (default: %(default)s)' ) + parser.add_argument('--local-access-remote', default='no', + choices=['yes', 'no'], + help='Local content can access remote URL (default: %(default)s)' + ) parser.add_argument('--proxy', metavar='address:port', help='Set the network proxy' ) diff --git a/python/pyphantomjs/webpage.py b/python/pyphantomjs/webpage.py index ba584192..3c5c3851 100644 --- a/python/pyphantomjs/webpage.py +++ b/python/pyphantomjs/webpage.py @@ -117,6 +117,7 @@ class WebPage(QObject): opt.setAttribute(QWebSettings.AutoLoadImages, defaults['loadImages']) opt.setAttribute(QWebSettings.PluginsEnabled, defaults['loadPlugins']) + opt.setAttribute(QWebSettings.LocalContentCanAccessRemoteUrls, defaults['localAccessRemote']) if 'userAgent' in defaults: self.m_webPage.m_userAgent = defaults['userAgent']