diff --git a/pywb/rewrite/regex_rewriters.py b/pywb/rewrite/regex_rewriters.py index ca67401e..c213063c 100644 --- a/pywb/rewrite/regex_rewriters.py +++ b/pywb/rewrite/regex_rewriters.py @@ -186,13 +186,13 @@ if (!self.__WB_pmw) {{ self.__WB_pmw = function(obj) {{ return obj; }} }}\n\ return lambda x: x.replace('this', replacer) def __init__(self, rewriter, rules=[]): - func_rw = 'Function("return {0}")'.format(self.THIS_RW) - + #func_rw = 'Function("return {0}")'.format(self.THIS_RW) prop_str = '|'.join(self.local_objs) rules = rules + [ (r'(?<=\.)postMessage\b\(', self.add_prefix('__WB_pmw(self).'), 0), - (r'Function\(["\']return this["\']\)', self.fixed(func_rw), 0), + #(r'Function\(["\']return this["\']\)', self.fixed(func_rw), 0), + (r'\breturn\s+this\b\s*(?![.$])', self.replace_str(self.THIS_RW), 0), (r'(?<=[\n])\s*this\b(?=(?:\.(?:{0})\b))'.format(prop_str), self.replace_str(';' + self.THIS_RW), 0), (r'(?>> _test_js_obj_proxy('func(Function("return this"));') 'func(Function("return (this && this._WB_wombat_obj_proxy || this)"));' +>>> _test_js_obj_proxy('A.call(function() { return this });') +'A.call(function() { return (this && this._WB_wombat_obj_proxy || this) });' + >>> _test_js_obj_proxy('this.document.location = foo') '(this && this._WB_wombat_obj_proxy || this).document.location = foo' @@ -167,6 +170,9 @@ r""" >>> _test_js_obj_proxy('|||this|||') '|||this|||' +>>> _test_js_obj_proxy('return this.foo') +'return this.foo' + #================================================================= # XML Rewriting