mirror of
https://github.com/webrecorder/pywb.git
synced 2025-03-28 00:25:21 +01:00
server-side rewrite: fix '#' rewriting
- only encode from request, not in WbUrl in general - tests: add live rewrite test to ensure encoded '#' is used
This commit is contained in:
parent
3e9087df3c
commit
af0f9c22cb
@ -135,6 +135,7 @@ class RewriterApp(object):
|
|||||||
return is_timegate
|
return is_timegate
|
||||||
|
|
||||||
def render_content(self, wb_url, kwargs, environ):
|
def render_content(self, wb_url, kwargs, environ):
|
||||||
|
wb_url = wb_url.replace('#', '%23')
|
||||||
wb_url = WbUrl(wb_url)
|
wb_url = WbUrl(wb_url)
|
||||||
is_timegate = self._check_accept_dt(wb_url, environ)
|
is_timegate = self._check_accept_dt(wb_url, environ)
|
||||||
|
|
||||||
|
@ -54,7 +54,7 @@ u"""
|
|||||||
"('latest_replay', '', '', 'http://example.com?example=2', 'http://example.com?example=2')"
|
"('latest_replay', '', '', 'http://example.com?example=2', 'http://example.com?example=2')"
|
||||||
|
|
||||||
>>> repr(WbUrl('http://example.com/xyz##abc'))
|
>>> repr(WbUrl('http://example.com/xyz##abc'))
|
||||||
"('latest_replay', '', '', 'http://example.com/xyz%23%23abc', 'http://example.com/xyz%23%23abc')"
|
"('latest_replay', '', '', 'http://example.com/xyz##abc', 'http://example.com/xyz##abc')"
|
||||||
|
|
||||||
# support urn: prefix
|
# support urn: prefix
|
||||||
>>> repr(WbUrl('urn:X-wpull:log'))
|
>>> repr(WbUrl('urn:X-wpull:log'))
|
||||||
|
@ -148,7 +148,6 @@ class WbUrl(BaseWbUrl):
|
|||||||
|
|
||||||
if six.PY2 and isinstance(scheme_dom, six.binary_type):
|
if six.PY2 and isinstance(scheme_dom, six.binary_type):
|
||||||
if scheme_dom == parts[0]:
|
if scheme_dom == parts[0]:
|
||||||
url = url.replace('#', '%23')
|
|
||||||
return url
|
return url
|
||||||
|
|
||||||
scheme_dom = scheme_dom.decode('utf-8', 'ignore')
|
scheme_dom = scheme_dom.decode('utf-8', 'ignore')
|
||||||
@ -178,7 +177,6 @@ class WbUrl(BaseWbUrl):
|
|||||||
|
|
||||||
url += rest
|
url += rest
|
||||||
|
|
||||||
url = url.replace('#', '%23')
|
|
||||||
return url
|
return url
|
||||||
|
|
||||||
# ======================
|
# ======================
|
||||||
|
@ -24,6 +24,11 @@ class TestLiveRewriter(BaseConfigTest):
|
|||||||
assert '"test": "abc"' in resp.text
|
assert '"test": "abc"' in resp.text
|
||||||
assert resp.status_int == 200
|
assert resp.status_int == 200
|
||||||
|
|
||||||
|
def test_live_anchor_encode(self, fmod_sl):
|
||||||
|
resp = self.get('/live/{0}httpbin.org/anything/abc%23%23xyz', fmod_sl)
|
||||||
|
assert '"http://httpbin.org/anything/abc##xyz"' in resp.text
|
||||||
|
assert resp.status_int == 200
|
||||||
|
|
||||||
def test_live_live_frame(self):
|
def test_live_live_frame(self):
|
||||||
resp = self.testapp.get('/live/http://example.com/')
|
resp = self.testapp.get('/live/http://example.com/')
|
||||||
assert resp.status_int == 200
|
assert resp.status_int == 200
|
||||||
|
Loading…
x
Reference in New Issue
Block a user