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

Allow local PDF files to be viewed in local frames #6941

Merged
merged 1 commit into from
Feb 10, 2016

Conversation

Rob--W
Copy link
Member

@Rob--W Rob--W commented Jan 30, 2016

The Chrome extension enforces that local files cannot be embedded in non-local web pages. The previous check was too strict (because the origin of a file:-URL is "null"), and prevented local PDF from being viewed in local files).
This bug was reported by a user in the Chrome Web Store:

it does not open a local file. it gives following error Page:1 Blocked null from loading file:///D:/abc.pdf. Refused to load a local file in a non-local page for security reasons.

This patch fixes that problem, by querying the actual tab URL via the background page.

Steps to verify:

  1. Create a HTML file: <iframe src=test.pdf width=100% height=100%>
  2. Build and load the extension.
  3. Allow file access to the extension at chrome://extensions
  4. Open the HTML file from a file:// URL.
  5. VERIFY: The extension should attempt to load the PDF file.
  6. Now open the following (replace ID with the extension ID, which you
    can find at chrome://extensions):
    data:text/html,<iframe src="chrome-extension://ID/file:///test.pdf">
  7. VERIFY: The next error should be displayed:
    "Refused to load a local file in a non-local page for security reasons."

@timvandermeij
Copy link
Contributor

Looks good after these comments have been addressed. I have confirmed that this patch works using the provided steps.

The Chrome extension enforces that local files cannot be embedded in
non-local web pages. The previous check was too strict (because the
origin of a file:-URL is "null"), and prevented local PDF from being
viewed in local files).

This patch fixes that problem, by querying the actual tab URL via the
background page.

Steps to verify:
1. Create a HTML file: `<iframe src=test.pdf width=100% height=100%>`
2. Build and load the extension.
3. Allow file access to the extension at `chrome://extensions`
4. Open the HTML file from a file:// URL.
5. VERIFY: The extension should attempt to load the PDF file.

6. Now open the following (replace ID with the extension ID, which you
   can find at `chrome://extensions`):
  `data:text/html,<iframe src="chrome-extension://ID/file:///test.pdf">`
7. VERIFY: The next error should be displayed:
   "Refused to load a local file in a non-local page for security reasons."
@Rob--W Rob--W force-pushed the crx-allow-pdf-in-local-frames branch from 096e571 to 0ec82d4 Compare February 10, 2016 13:53
@timvandermeij
Copy link
Contributor

/botio-linux preview

@pdfjsbot
Copy link

From: Bot.io (Linux)


Received

Command cmd_preview from @timvandermeij received. Current queue size: 1

Live output at: http://107.21.233.14:8877/019435c15af83bd/output.txt

timvandermeij added a commit that referenced this pull request Feb 10, 2016
Allow local PDF files to be viewed in local frames
@timvandermeij timvandermeij merged commit acf74d4 into mozilla:master Feb 10, 2016
@timvandermeij
Copy link
Contributor

Verified, thank you!

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

Successfully merging this pull request may close these issues.

3 participants