mirror of
https://github.com/webrecorder/pywb.git
synced 2025-03-15 00:03:28 +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
|
||||
|
||||
def render_content(self, wb_url, kwargs, environ):
|
||||
wb_url = wb_url.replace('#', '%23')
|
||||
wb_url = WbUrl(wb_url)
|
||||
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')"
|
||||
|
||||
>>> 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
|
||||
>>> repr(WbUrl('urn:X-wpull:log'))
|
||||
|
@ -148,7 +148,6 @@ 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')
|
||||
@ -178,7 +177,6 @@ class WbUrl(BaseWbUrl):
|
||||
|
||||
url += rest
|
||||
|
||||
url = url.replace('#', '%23')
|
||||
return url
|
||||
|
||||
# ======================
|
||||
|
@ -24,6 +24,11 @@ class TestLiveRewriter(BaseConfigTest):
|
||||
assert '"test": "abc"' in resp.text
|
||||
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):
|
||||
resp = self.testapp.get('/live/http://example.com/')
|
||||
assert resp.status_int == 200
|
||||
|
Loading…
x
Reference in New Issue
Block a user