Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Image in blog is 404, resolving against extension vs. original domain #522

Open
humphd opened this issue Dec 19, 2019 · 3 comments
Open

Comments

@humphd
Copy link

humphd commented Dec 19, 2019

I'm not sure if this is the right repo for bugs in Mercury Reader, so let me know if there is a better repo for it.

  • Platform: macOS 10.14.6
  • Mercury Parser Version: 4.3.1.0
  • Node Version (if a Node bug):
  • Browser Version (if a browser bug): Chrome Version 79.0.3945.79 (Official Build) (64-bit)

Expected Behavior

Images using paths /from/the/root should work when shown using the Mercury Reader. For example, on https://blog.humphd.org/open-source-fall-2019/, there is an <img src="/content/images/2019/12/telescope-gource.png"> element, which displays correctly in normal view.

Current Behavior

Using Mercury Reader, the same image is a 404. The path has been resolved relative to the extension, and becomes chrome-extension://oknpjjbmpnndlpmnhmekjpocelpnlfdi/content/images/2019/12/telescope-gource.png, which can't be found.

Steps to Reproduce

  • Go to https://blog.humphd.org/open-source-fall-2019/
  • Scroll down to notice that there is an image in the post
  • Enable Mercury Reader on the page
  • Notice that the image has been broken, and a 404 appears in the console.
  • In the dev tools, inspect the broken <img> and hover the src value, which is now shown as chrome-extension://oknpjjbmpnndlpmnhmekjpocelpnlfdi/content/images/2019/12/telescope-gource.png

Here is a screenshot, with the page loaded normally on the left, in Mercury Reader o the right:

Screen Shot 2019-12-19 at 2 17 46 PM

Possible Solution

I don't know how the Reader code works, but it appears that the relative URL is being made absolute, and resolved relative to the extension's domain vs. the blog's.

@jdq22
Copy link

jdq22 commented Jan 15, 2020

We're also having this issue.

@humphd
Copy link
Author

humphd commented Jan 15, 2020

I've had to deal with this bug in other contexts, and I did it using a <base> element, to make sure that relative URLs resolved properly.

I notice in the <iframe> your extension injects, you have this in the document:

<base target="_parent">

If your <base> element also included an href="url-to-original-site" attribute, I bet it would fix this.

@kibiz0r
Copy link

kibiz0r commented Aug 17, 2021

Can confirm, also having this issue.

@humphd's proposed solution seems to work.

I started to write a TamperMonkey script to work around this, but cross-site scripting protections make it rather annoying. If someone puts in the time to do it, I'd love to know about it.

What are the chances we'll get a real fix, after 2 years of this issue being open with no reply? Is this extension just dead?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants