Greasemonkey: Match against percent encoded urls only.
This change requires urls specified in @include, @exclude and @matches directives in metadata blocks to be in the same form that QUrl.toEncoded() returns. That is a punycoded domain and percent encoded path and query. This seems to be what Tampermonkey on chrome expects to. Also changes the scripts_for() function to take a QUrl arg so the caller doesn't need to worry about encodings.
This commit is contained in:
parent
d318178567
commit
209e43e0ba
@ -181,9 +181,10 @@ class GreasemonkeyManager(QObject):
|
||||
returns a tuple of lists of scripts meant to run at (document-start,
|
||||
document-end, document-idle)
|
||||
"""
|
||||
if url.split(':', 1)[0] not in self.greaseable_schemes:
|
||||
if url.scheme() not in self.greaseable_schemes:
|
||||
return MatchingScripts(url, [], [], [])
|
||||
match = functools.partial(fnmatch.fnmatch, url)
|
||||
match = functools.partial(fnmatch.fnmatch,
|
||||
str(url.toEncoded(), 'utf-8'))
|
||||
tester = (lambda script:
|
||||
any([match(pat) for pat in script.includes]) and
|
||||
not any([match(pat) for pat in script.excludes]))
|
||||
|
@ -300,7 +300,7 @@ class BrowserPage(QWebPage):
|
||||
"""
|
||||
greasemonkey = objreg.get('greasemonkey')
|
||||
url = self.currentFrame().url()
|
||||
scripts = greasemonkey.scripts_for(url.toDisplayString())
|
||||
scripts = greasemonkey.scripts_for(url)
|
||||
|
||||
if load == "start":
|
||||
toload = scripts.start
|
||||
|
Loading…
Reference in New Issue
Block a user