Problem/Motivation

Using Webform Share’s (6.0.0-beta2) javascript option to embed an https form onto to a non-drupal page served on http, I’m seeing the resize fail, apparently because of the drupal-side redirect to https. Because the javascript option used the protocol by which the parent page is accessed, the shared form loads in but only a portion of the fields display, as in the attached screenshot.

Using the “Resizing iframe” option in Webform Share does the same thing, but in that case I can add the https protocol into the frame’s src attribute and the frame loads and resizes as expected. The “JavaScript” option, though, always generates a protocol-less frame src, even when I add the protocol into the src attribute of the script tag.

Steps to reproduce

End user experience

1. On a drupal site which forces https, create a webform, enable sharing, and copy the javascript share code.
2. Paste the code into a parent page and access that page over http.
3. Observe the form is only partially displayed.
4. In the parent page, amend the content of the embed script to include https as the protocol.
5. Reload the page.
6. Observe the same behavior as #3.

Proposed resolution

Amend the generated javascript share script to respect a protocol if included in the script's src attribute.

Remaining tasks

TBD

User interface changes

N/A

API changes

TBD

Data model changes

N/A

Comments

Barrett created an issue. See original summary.

jrockowitz’s picture

Status: Active » Needs review
StatusFileSize
new874 bytes

I don't have an easy way to replicate this issue. Attached is my best guess at the solution.

jrockowitz’s picture

Version: 6.0.0-beta2 » 8.x-5.x-dev

This issue should be fixed 8.x-5.x

jrockowitz’s picture

StatusFileSize
new874 bytes
barrett’s picture

Status: Needs review » Needs work

No joy on the patch, but I think it's the right direction.

Using the javascript location.protocol is getting the protocol by which the parent page is requested, so http in the case I'm encountering, when it needs https. I think changing that in the controller to use Request::getScheme() instead will allow the script to be accessed on https and result in an iframe that uses an https source.

I'll test that out locally and roll a new patch if it works.

jrockowitz’s picture

Yes. I need help with this patch. Thanks

barrett’s picture

Status: Needs work » Needs review
StatusFileSize
new877 bytes

Here's a variant of your patch that uses $request->getScheme(). It's working in my testing, thus far.

You can see an example of what the script spits out at https://www.datasmith.net/webform/test/share.js

jrockowitz’s picture

An issue with including the schema is if a website is behind a load balancer where the HTTPS request terminates at the load balancer and each server is getting an HTTP request. I hope that makes sense.

We might want to let this patch sit around and see if other people are running into this issue.

barrett’s picture

Component: Code » Translation

Yeah, I see what you're saying. I don't have any objection to letting the issue sit for a bit and seeing if anyone else has different results.

I'm testing on Acquia hosting, where SSL is terminated at the balancers, and this patch seems to be working. I _think_ that's because getScheme() calls isSecure() which checks the x-forwarded-proto header. Certainly possible though that other server configurations wouldn't work the same way.

barrett’s picture

Component: Translation » Code

[correcting component which I somehow set to "translation" by mistake]

jrockowitz’s picture

Hmm... maybe we should just apply this patch to 6.x and call it a day.

jrockowitz’s picture

Here is the plan...this will be committed immediately after the next stable release of 8.x-5.x and 6.x in the hope that people will discover any regressions via the dev and beta release.

  • Barrett authored 9e73066 on 8.x-5.x
    Issue #3186943 by jrockowitz, Barrett: Webform Share javascript option...

  • Barrett authored 9e73066 on 6.x
    Issue #3186943 by jrockowitz, Barrett: Webform Share javascript option...
jrockowitz’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.