mirror of
https://github.com/webrecorder/pywb.git
synced 2025-03-15 00:03:28 +01:00
Server-Side Rewrite: 'location' rewrite fix to avoid rewriting '$location' (#403)
* server-side rewrite: tweak 'location' rewrite to ensure $location is not rewritten! tests: add additional rewrite tests for 'location', 'this.$location' and 'this.location'
This commit is contained in:
parent
e1e8917bc3
commit
f805f79388
@ -93,7 +93,7 @@ if (!self.__WB_pmw) {{ self.__WB_pmw = function(obj) {{ return obj; }} }}\n\
|
||||
|
||||
rules = [
|
||||
(r'(?<=\.)postMessage\b\(', self.add_prefix('__WB_pmw(self).'), 0),
|
||||
(r'(?<!\.)\blocation\b\s*[=]\s*(?![=])', self.add_suffix(check_loc), 0),
|
||||
(r'(?<![$.])\s*location\b\s*[=]\s*(?![=])', self.add_suffix(check_loc), 0),
|
||||
(r'\breturn\s+this\b\s*(?![.$])', self.replace_str(this_rw), 0),
|
||||
(r'(?<=[\n])\s*this\b(?=(?:\.(?:{0})\b))'.format(prop_str), self.replace_str(';' + this_rw), 0),
|
||||
(r'(?<![$.])\s*this\b(?=(?:\.(?:{0})\b))'.format(prop_str), self.replace_str(this_rw), 0),
|
||||
|
@ -194,6 +194,22 @@ r"""
|
||||
>>> _test_js_obj_proxy('return this.foo')
|
||||
'return this.foo'
|
||||
|
||||
>>> _test_js_obj_proxy(r'this.$location = http://example.com/')
|
||||
'this.$location = http://example.com/'
|
||||
|
||||
>>> _test_js_obj_proxy(r'this. $location = http://example.com/')
|
||||
'this. $location = http://example.com/'
|
||||
|
||||
>>> _test_js_obj_proxy(r'this. _location = http://example.com/')
|
||||
'this. _location = http://example.com/'
|
||||
|
||||
>>> _test_js_obj_proxy(r'this. alocation = http://example.com/')
|
||||
'this. alocation = http://example.com/'
|
||||
|
||||
>>> _test_js_obj_proxy(r'this. location = http://example.com/')
|
||||
'this. location = (self.__WB_check_loc && self.__WB_check_loc(location) || {}).href = http://example.com/'
|
||||
|
||||
|
||||
|
||||
#=================================================================
|
||||
# XML Rewriting
|
||||
|
Loading…
x
Reference in New Issue
Block a user