webrecorder / pywb

Core Python Web Archiving Toolkit for replay and recording of web archives
https://pypi.python.org/pypi/pywb
GNU General Public License v3.0
1.41k stars 217 forks source link

`this` rewriting can affect dynamically generated content on the page #879

Open the-blank-x opened 10 months ago

the-blank-x commented 10 months ago

Describe the bug

pywb rewrites all this uses to use a wrapper. However, the rewriting can be a bit overzealous, since it does so inside strings. For example, document.querySelector("p").innerText = "well, this is awkward" gets rewritten into document.querySelector("p").innerText = "well, _____WB$wombat$check$this$function_____(this) is awkward"

Steps to reproduce the bug

  1. Download test.warc.gz
  2. wb-manager init test
  3. wb-manager add test test.warc.gz
  4. Go to http://localhost:8080/test/http://localhost:8000/ (for an example), or http://localhost:8080/test/https://stainedglasswoman.substack.com/p/slivers (for an occurance in the wild)

Expected behavior

The rewrite to not hapen inside strings

Screenshots

Environment