1
0
mirror of https://github.com/webrecorder/pywb.git synced 2025-03-15 00:03:28 +01:00

rewriting fixes:

- wburl: escape any '#' -> '%23' (presumably unescaped by wsgi), add tests
- wombat: call proxy_to_obj() for overriden property accessors
This commit is contained in:
Ilya Kreymer 2017-10-19 15:41:32 -07:00
parent 9c574db7da
commit 456ac09b62
3 changed files with 14 additions and 4 deletions

View File

@ -53,6 +53,9 @@ u"""
>>> repr(WbUrl('http://example.com?example=2'))
"('latest_replay', '', '', 'http://example.com?example=2', 'http://example.com?example=2')"
>>> repr(WbUrl('http://example.com/xyz##abc'))
"('latest_replay', '', '', 'http://example.com/xyz%23%23abc', 'http://example.com/xyz%23%23abc')"
# support urn: prefix
>>> repr(WbUrl('urn:X-wpull:log'))
"('latest_replay', '', '', 'urn:X-wpull:log', 'urn:X-wpull:log')"

View File

@ -148,6 +148,7 @@ class WbUrl(BaseWbUrl):
if six.PY2 and isinstance(scheme_dom, six.binary_type):
if scheme_dom == parts[0]:
url = url.replace('#', '%23')
return url
scheme_dom = scheme_dom.decode('utf-8', 'ignore')
@ -177,6 +178,7 @@ class WbUrl(BaseWbUrl):
url += rest
url = url.replace('#', '%23')
return url
# ======================

View File

@ -882,8 +882,9 @@ var _WBWombat = function($wbwindow, wbinfo) {
var orig_getter = get_orig_getter(proto, prop);
if (orig_getter) {
var new_getter = function() {
var res = orig_getter.call(this);
if (!cond || cond(this)) {
var obj = proxy_to_obj(this);
var res = orig_getter.call(obj);
if (!cond || cond(obj)) {
res = extract_orig(res);
}
return res;
@ -2395,10 +2396,14 @@ var _WBWombat = function($wbwindow, wbinfo) {
value = cookies.join(",")
return orig_set_cookie.call(this, value);
return orig_set_cookie.call(proxy_to_obj(this), value);
}
def_prop($wbwindow.document, "cookie", set_cookie, orig_get_cookie);
function get_cookie() {
return orig_get_cookie.call(proxy_to_obj(this));
}
def_prop($wbwindow.document, "cookie", set_cookie, get_cookie);
}
//============================================