From f805f79388b92d17e5a65f84ebba74e3ee54d4d3 Mon Sep 17 00:00:00 2001 From: Ilya Kreymer Date: Wed, 31 Oct 2018 20:18:18 -0700 Subject: [PATCH] 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' --- pywb/rewrite/regex_rewriters.py | 2 +- pywb/rewrite/test/test_regex_rewriters.py | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/pywb/rewrite/regex_rewriters.py b/pywb/rewrite/regex_rewriters.py index 69dbef32..686ad632 100644 --- a/pywb/rewrite/regex_rewriters.py +++ b/pywb/rewrite/regex_rewriters.py @@ -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'(?>> _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