product-backlog
product-backlog copied to clipboard
OpenStax book embedded as a URL in the LMS app keeps Hypothesis embedded, with "LMS" in the URL, when links are clicked
Bug report form
Steps to reproduce
- Create an assignment from the page https://openstax.org/books/university-physics-volume-1/pages/1-introduction (example here, login in 1pass: "Canvas: Professor D")
- Click a link on that page
- Link opens in a new tab with a URL like: https://lms-viahtml.hypothes.is/proxy/mp_/https://openstax.org/books/university-physics-volume-1/pages/1-1-the-scope-and-scale-of-physics
- App is embedded, Public group is visible.
Expected behaviour
The page should open in a new tab, but without "https://lms-viahtml.hypothes.is/proxy/mp_/" and without the app embedded or in via at all.
Browser/system information
Chrome 107 MacOS 11.6
Additional details
Old issue with OpenStax here: https://github.com/hypothesis/product-backlog/issues/1273. Recently closed as the old issue seems to no longer happen. May also be related to: https://github.com/hypothesis/viahtml/issues/423
It looks like the logic we have for preventing the URLs of <a>
links in the original page from being rewritten into proxy links (see https://github.com/hypothesis/viahtml/blob/bd5ecfa387ff84a0d2c093e37469dce3500d0bab/viahtml/hooks/hooks.py#L96) is not working in this case.
What is supposed to happen for <a>
links on the page is:
- On the backend, we prevent these links from being rewritten to go through ViaHTML
- On the frontend, we add a JS "click" handler for the document that adds
target=_blank
to the link when it is clicked, so it opens in an external tab (see https://github.com/hypothesis/viahtml/blob/bd5ecfa387ff84a0d2c093e37469dce3500d0bab/viahtml/templates/banner.html#L90)