mirror of
https://github.com/webrecorder/pywb.git
synced 2025-03-15 00:03:28 +01:00
server side rewriting: (#475)
- fixed edge case in jsonP rewriting where no callback name is supplied only ? but body has normal jsonP callback (url = https://geolocation.onetrust.com/cookieconsentpub/v1/geo/countries/EU?callback=?) - made the `!self.__WB_pmw` server side inject match the client side one done via wombat - added regex's for eval override to JSWombatProxyRules
This commit is contained in:
parent
14f7aad5eb
commit
749f50ca92
@ -19,6 +19,12 @@ class JSONPRewriter(StreamingRewriter):
|
||||
m_callback = self.CALLBACK.search(self.url_rewriter.wburl.url)
|
||||
if not m_callback:
|
||||
return string
|
||||
if m_callback.group(1) == '?':
|
||||
# this is a very sharp edge case e.g. callback=?
|
||||
# since we only have this string[m_json.end(1):]
|
||||
# would cut off the name of the CB if any is included
|
||||
# so we just pass the string through
|
||||
return string
|
||||
|
||||
string = m_callback.group(1) + string[m_json.end(1):]
|
||||
return string
|
||||
|
@ -65,7 +65,7 @@ class JSWombatProxyRules(RxRules):
|
||||
local_init_func = '\nvar {0} = function(name) {{\
|
||||
return (self._wb_wombat && self._wb_wombat.local_init && \
|
||||
self._wb_wombat.local_init(name)) || self[name]; }};\n\
|
||||
if (!self.__WB_pmw) {{ self.__WB_pmw = function(obj) {{ return obj; }} }}\n\
|
||||
if (!self.__WB_pmw) {{ self.__WB_pmw = function(obj) {{ this.__WB_source = obj; return this; }} }}\n\
|
||||
{{\n'
|
||||
local_check_this_fn = 'var {0} = function (thisObj) {{ \
|
||||
if (thisObj && thisObj._WB_wombat_obj_proxy) return thisObj._WB_wombat_obj_proxy; return thisObj; }};'
|
||||
@ -102,6 +102,8 @@ if (thisObj && thisObj._WB_wombat_obj_proxy) return thisObj._WB_wombat_obj_proxy
|
||||
prop_str = '|'.join(self.local_objs)
|
||||
|
||||
rules = [
|
||||
(r'\beval\s*\(', self.add_prefix('WB_wombat_runEval(function _____evalIsEvil(_______eval_arg$$) { return eval(_______eval_arg$$); }.bind(this)).'), 0),
|
||||
(r'\beval\b', self.add_prefix('WB_wombat_'), 0),
|
||||
(r'(?<=\.)postMessage\b\(', self.add_prefix('__WB_pmw(self).'), 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),
|
||||
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
Loading…
x
Reference in New Issue
Block a user