diff --git a/pywb/apps/rewriterapp.py b/pywb/apps/rewriterapp.py index f199be68..68690b1a 100644 --- a/pywb/apps/rewriterapp.py +++ b/pywb/apps/rewriterapp.py @@ -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) diff --git a/pywb/rewrite/test/test_wburl.py b/pywb/rewrite/test/test_wburl.py index 7267d4ad..beefbbdd 100644 --- a/pywb/rewrite/test/test_wburl.py +++ b/pywb/rewrite/test/test_wburl.py @@ -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')) diff --git a/pywb/rewrite/wburl.py b/pywb/rewrite/wburl.py index 38eb5db0..3d98fdd5 100644 --- a/pywb/rewrite/wburl.py +++ b/pywb/rewrite/wburl.py @@ -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 # ====================== diff --git a/tests/test_live_rewriter.py b/tests/test_live_rewriter.py index ddb3d018..f4ac365d 100644 --- a/tests/test_live_rewriter.py +++ b/tests/test_live_rewriter.py @@ -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