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

Let iframe use relative URL instead of absolute #6246

Closed
sean-xiao-zhao7 opened this issue Oct 22, 2018 · 10 comments
Closed

Let iframe use relative URL instead of absolute #6246

sean-xiao-zhao7 opened this issue Oct 22, 2018 · 10 comments

Comments

@sean-xiao-zhao7
Copy link

See https://forum.pkp.sfu.ca/t/pdf-js-viewer-fails-when-proxied-fix-and-solution/18257
The current iframe URL does not work with EZProxy setups.
EZProxy is unable to correctly calculate the base URL - it always seems to use the non-ezproxyed base URL.

After discussion with Clinton Graham, we've came up with a solution.
I'd like to submit a PR on this repo for this fix.

@asmecher
Copy link
Member

@sean-xiao-zhao7, please do!

shorock referenced this issue in shorock/pdfJsViewer Apr 2, 2019
…marty so EZProxy installs can see the URL and rewrite it (if they use a DomainJavascript directive).

Fixes #34.
shorock referenced this issue in shorock/pdfJsViewer Apr 2, 2019
… so EZProxy installs can see the URL and rewrite it.

(EZProxy config will need a DomainJavascript directive for this).

Fixes #34.
shorock referenced this issue in shorock/pdfJsViewer Apr 2, 2019
… so EZProxy installs can see the URL and rewrite it.

(EZProxy config will need a DomainJavascript directive for this).

Fixes #34.
shorock referenced this issue in shorock/pdfJsViewer Apr 2, 2019
…roxy rewriting.

(Remote) EZProxy config will need a DomainJavascript directive for this.

Fixes #34.
shorock referenced this issue in shorock/pdfJsViewer Apr 2, 2019
…rewriting.

(Remote) EZProxy config will need a DomainJavascript directive for this.

Fixes #34.
shorock referenced this issue in shorock/pdfJsViewer Apr 2, 2019
…rewriting.

(Remote) EZProxy config will need a DomainJavascript directive for this.

Fixes #34.
@asmecher asmecher transferred this issue from pkp/pdfJsViewer Sep 21, 2020
@asmecher asmecher added this to the OJS/OMP/OPS 3.2.1-2 milestone Sep 21, 2020
@asmecher
Copy link
Member

Merged manually for release in OJS and OPS 3.2.1-2; ported to OMP for release in 3.2.1-2.

@asmecher
Copy link
Member

Thanks, @sean-xiao-zhao7!

@wangra8
Copy link

wangra8 commented Jan 18, 2021

Hi Everyone! Happy New Year! 🎉

I'd like to add to this conversation in 2021 because a journal subscriber last week opened a ticket about urls breaking again due to EZProxy. We found that the merged solution in this thread was not enough to solve it. I would like to add our additional solution at (UofT Libraries) included modifications to the javascript in the/pdfJsViewer/templates/display.tpl template file. In order for this change to be enabled across the board, the display.tpl file had to be replaced in all our themes that used pdfJsViewer/templates/display.tpl.

As per your readme, I didn't want to open another issue, so do let me know what's the procedure if I'd like to contribute to an older issue that's reappeared. Many thanks to the original developers who provided the solution. For context, I'm now Sean's successor at (UofT Libraries), so happy to contribute to the solution once again. Thank you, take care and stay safe.

<script type="text/javascript">
// Creating iframe's src in JS instead of Smarty so that EZProxy-using sites can find our domain in $pdfUrl and do their rewrites on it.
            $(document).ready(function() {ldelim}
            var urlBase = "{$pluginUrl}/pdf.js/web/viewer.html?file=";
            var pdfUrl = "{$pdfUrl}";
            var encodedPdfUrl = encodeURIComponent(pdfUrl);
            encodedPdfUrl = encodedPdfUrl.replace("https%3A%2F%2F", "https://").replace("http%3A%2F%2F", "http://");
            $("#pdfCanvasContainer > iframe").attr("src", urlBase + encodedPdfUrl);
            {rdelim});
</script>

@jnugent
Copy link
Member

jnugent commented Jan 19, 2021

+1 for @wangra8 's fix. This was timely - I confirm that this solved an exProxy issue with a hosted client this morning.

@asmecher
Copy link
Member

Good to hear that this is helpful for 2 different installs, but I'm confused about why EZProxy isn't rewriting the URLs where they're declared with the JS var statement. Adding the javascript flag to the EZProxy config should permit that. Or am I misunderstanding the problem?

@wangra8
Copy link

wangra8 commented Jan 20, 2021

Hi Everyone! 👋

I'm glad to hear it helped solve the issue for someone else too. 😃 I'm afraid I don't have the root cause about why EZProzy suddenly stopped rewriting the URLs, but we know that the user which reported the issue, updated their EZProxy which then broke the URLs. We ruled out ojs upgrade breaking this because our last upgrade was to 3.1.2 was in November 2019.

When this broke, iframes started looking like this, so we went with the quickest solution possible which was to rewrite it manually with javascript. I'm open to a more elegant solution, for now we have deployed this into production to keep this from happening again to our users. Thank you and stay safe!

Update: Oops, forgot to ask, should I open a new issue and create a PR?

--Rachel

<iframe src="http://ojsdev.scholarsportal.info/toronto/plugins/
generic/pdfJsViewer/pdf.js/web/viewer.html?file=http%3A%2F%2Fojsdev.scholarsportal.info
%2Ftoronto%2Findex.php%2Fscientonomy%2Farticle%2Fdownload%2F33509%2F25800%2F" 

@asmecher
Copy link
Member

Thanks, @wangra8, that helps. So it sounds like an EZProxy update caused the change in behaviour? What was the previous version of EZProxy, and what are you using now?

@wangra8
Copy link

wangra8 commented Jan 20, 2021

Hi @asmecher & Everyone! 👋

Sorry I have to retract my statement that EZProxy update was the root cause. I haven't worked with this particular functionality of OJS too much so I went back and checked in with my awesome team members 😄 🌟 and these are the pieces of information I'm going to share. 🤓 📖

At the end of the Iter Stanza file the following worked fine.

Find jps.library.utoronto.ca
Replace ^sjps.library.utoronto.ca^

Then in the past few months a different resource that we proxy introduced this line into EZP's config.txt

DJ	utoronto.ca
  • This additional line interfered with the JavaScript Find/Replace. After removing DJ utoronto.ca, the Find/Replace worked again.
  • The problem is not specific to OJS. We were able to replicate identical behaviour with other domains that we host.
  • We're currently on EZProxy version 6.5.1 GA

I hope this makes the root cause clearer, let me know, I will do my best to answer! Thank you & stay safe!

---Rachel

@asmecher
Copy link
Member

New issue filed here --> pkp/pdfJsViewer#60

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

4 participants