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

Rewrite: Support target rewriting, open new windows in top-frame instead (#767)

* Bump wombat to 3.3.9

* Set target attributes to iframe name
This commit is contained in:
Tessa Walsh 2022-10-05 20:55:12 -04:00 committed by GitHub
parent 98378a8845
commit 815ea92fc2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 14 additions and 2 deletions

View File

@ -433,6 +433,12 @@ class HTMLRewriterMixin(StreamingRewriter):
# URL not skipped, likely src='js/....', forcing abs to make sure, cause PHP MIME(JS) === HTML # URL not skipped, likely src='js/....', forcing abs to make sure, cause PHP MIME(JS) === HTML
attr_value = self._rewrite_url(attr_value, rw_mod, True) attr_value = self._rewrite_url(attr_value, rw_mod, True)
self._write_attr('__wb_orig_src', ov, empty_attr=None) self._write_attr('__wb_orig_src', ov, empty_attr=None)
elif attr_name == 'target':
target = attr_value
if target in ('_blank', '_parent', '_top'):
attr_value = '___wb_replay_top_frame'
else: else:
# rewrite url using tag handler # rewrite url using tag handler
rw_mod = handler.get(attr_name) rw_mod = handler.get(attr_name)

View File

@ -416,6 +416,9 @@ r"""
>>> parse('<!--[if !IE]> --><html><![endif]--><a href="http://example.com/"><!--[if IE]><![endif]--><a href="http://example.com/"></html>') >>> parse('<!--[if !IE]> --><html><![endif]--><a href="http://example.com/"><!--[if IE]><![endif]--><a href="http://example.com/"></html>')
<!--[if !IE]> --><html><![endif]><a href="/web/20131226101010/http://example.com/"><!--[if IE]><![endif]--><a href="/web/20131226101010/http://example.com/"></html> <!--[if !IE]> --><html><![endif]><a href="/web/20131226101010/http://example.com/"><!--[if IE]><![endif]--><a href="/web/20131226101010/http://example.com/"></html>
# Test tag with a target
>>> parse('<HTML><A Href=\"page.html\" target=\"_blank\">Text</a></hTmL>')
<html><a href="page.html" target="___wb_replay_top_frame">Text</a></html>
# Test blank # Test blank
>>> parse('') >>> parse('')

View File

@ -65,6 +65,8 @@ ContentFrame.prototype.init_iframe = function() {
return; return;
} }
this.iframe.setAttribute("name", "___wb_replay_top_frame");
this.extract_prefix(); this.extract_prefix();
if (window.WBBanner) { if (window.WBBanner) {
this.wbBanner = window.WBBanner; this.wbBanner = window.WBBanner;

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -27,6 +27,7 @@
wbinfo.proxy_magic = "{{ env.pywb_proxy_magic }}"; wbinfo.proxy_magic = "{{ env.pywb_proxy_magic }}";
wbinfo.static_prefix = "{{ static_prefix }}/"; wbinfo.static_prefix = "{{ static_prefix }}/";
wbinfo.enable_auto_fetch = {{ config.enable_auto_fetch | tobool }}; wbinfo.enable_auto_fetch = {{ config.enable_auto_fetch | tobool }};
wbinfo.target_frame = "___wb_replay_top_frame";
</script> </script>
{% if env.pywb_proxy_magic %} {% if env.pywb_proxy_magic %}
{% set whichWombat = 'wombatProxyMode.js' %} {% set whichWombat = 'wombatProxyMode.js' %}