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

client-side top-frame notification fix:

- send_top_message() to wrap all postMessage calls
- url change, hash change, history change notifications only sent if window is top replay frame, cookie notification sent for all windows
- don't send url change notification if 'about:blank' or 'javascript:' url
bump version to 2.0.2
This commit is contained in:
Ilya Kreymer 2018-02-13 13:49:10 -08:00
parent fc48e23dae
commit 7234bc51f0
3 changed files with 31 additions and 23 deletions

View File

@ -1,5 +1,5 @@
Webrecorder pywb 2.0.0 Webrecorder pywb 2.0
====================== ====================
.. image:: https://travis-ci.org/webrecorder/pywb.svg?branch=master .. image:: https://travis-ci.org/webrecorder/pywb.svg?branch=master
:target: https://travis-ci.org/webrecorder/pywb :target: https://travis-ci.org/webrecorder/pywb

View File

@ -1,4 +1,4 @@
__version__ = '2.0.1' __version__ = '2.0.2'
DEFAULT_CONFIG = 'pywb/default_config.yaml' DEFAULT_CONFIG = 'pywb/default_config.yaml'

View File

@ -18,7 +18,7 @@ This file is part of pywb, https://github.com/webrecorder/pywb
*/ */
//============================================ //============================================
// Wombat JS-Rewriting Library v2.52 // Wombat JS-Rewriting Library v2.53
//============================================ //============================================
@ -795,18 +795,16 @@ var _WBWombat = function($wbwindow, wbinfo) {
//============================================ //============================================
function send_history_update(url, title) { function send_history_update(url, title) {
if ($wbwindow.__WB_top_frame && $wbwindow == $wbwindow.__WB_replay_top) { var message = {
var message = { "url": url,
"url": url, "ts": wb_info.timestamp,
"ts": wb_info.timestamp, "request_ts": wb_info.request_ts,
"request_ts": wb_info.request_ts, "is_live": wb_info.is_live,
"is_live": wb_info.is_live, "title": title,
"title": title, "wb_type": "replace-url",
"wb_type": "replace-url", }
}
$wbwindow.__WB_top_frame.postMessage(message, wb_info.top_host); send_top_message(message);
}
} }
//============================================ //============================================
@ -2141,9 +2139,7 @@ var _WBWombat = function($wbwindow, wbinfo) {
"hash": $wbwindow.location.hash "hash": $wbwindow.location.hash
} }
if ($wbwindow.__WB_top_frame) { send_top_message(message);
$wbwindow.__WB_top_frame.postMessage(message, wb_info.top_host);
}
} }
$wbwindow.addEventListener("message", receive_hash_change); $wbwindow.addEventListener("message", receive_hash_change);
@ -2485,9 +2481,7 @@ var _WBWombat = function($wbwindow, wbinfo) {
} }
// norify of cookie setting to allow server-side tracking // norify of cookie setting to allow server-side tracking
if ($wbwindow.__WB_top_frame) { send_top_message(message, true);
$wbwindow.__WB_top_frame.postMessage(message, wb_info.top_host);
}
// if no subdomain, eg. "localhost", just remove domain altogether // if no subdomain, eg. "localhost", just remove domain altogether
if ($wbwindow.location.hostname.indexOf(".") >= 0 && !IP_RX.test($wbwindow.location.hostname)) { if ($wbwindow.location.hostname.indexOf(".") >= 0 && !IP_RX.test($wbwindow.location.hostname)) {
@ -3289,7 +3283,9 @@ var _WBWombat = function($wbwindow, wbinfo) {
return; return;
} }
if (typeof($wbwindow.WB_wombat_location.href) != "string") { var url = $wbwindow.WB_wombat_location.href;
if (typeof(url) != "string" || url == "about:blank" || url.indexOf("javascript:") == 0) {
return; return;
} }
@ -3303,7 +3299,7 @@ var _WBWombat = function($wbwindow, wbinfo) {
"wb_type": "load" "wb_type": "load"
} }
$wbwindow.__WB_top_frame.postMessage(message, wbinfo.top_host); send_top_message(message);
} }
if ($wbwindow.document.readyState == "complete") { if ($wbwindow.document.readyState == "complete") {
@ -3315,6 +3311,18 @@ var _WBWombat = function($wbwindow, wbinfo) {
} }
} }
function send_top_message(message, skip_top_check) {
if (!$wbwindow.__WB_top_frame) {
return;
}
if (!skip_top_check && $wbwindow != $wbwindow.__WB_replay_top) {
return;
}
$wbwindow.__WB_top_frame.postMessage(message, wbinfo.top_host);
}
function init_top_frame($wbwindow) { function init_top_frame($wbwindow) {
// proxy mode // proxy mode
if (wb_is_proxy) { if (wb_is_proxy) {