Nice to see a simple does-what-you-need module! For responsive sites, it's useful to be able to specify the width in % instead of px.
I was able to accomplish this by removing the integer casts for iframe_width (and iframe_height) in simple_gmap.module. Was there any specific reason for using integer casts there?

CommentFileSizeAuthor
#13 1866434.fixwidths.patch2.38 KBjhodgdon

Comments

jhodgdon’s picture

Category: task » feature

I used integer casts to sanitize the data. I agree that the width could be specified in %, so this is a good feature request. The data still would need to be sanitized, so just removing the casts would not be enough.

CarbonPig’s picture

Thanks for sharing. Was having this same issue. Now I know what "integer casts" are.

FYI - for others:

(int)

To set my width to 100%, I had to remove (int) from 2 places in the module file where it was placed next to "width"

Not sure if this has any implications, but everything seems stable.

Thanks!

CP

jhodgdon’s picture

Version: 7.x-1.0 » 7.x-1.x-dev
Assigned: Unassigned » jhodgdon
Priority: Normal » Major

OK -- this is looking like something I should fix sooner rather than later. I'll have to do it slightly more carefully than just removing the (int) casts on the width, for security reasons, but I'll make sure that the module works with widths/heights in pixels, percents, or any other legal CSS specification of width/height. I'll try to get to this sometime soon.

mengi’s picture

Would love to see this as well. Is there a significant security issue with implementing the integer casts workaround?

jhodgdon’s picture

If you remove the (int) filtering, you still need to do something like check_plain() -- all user-entered input must be filtered in some way or it is a XSS security risk. I just haven't made time to fix this. Sorry. If someone would like to make a patch, that would be nice. :)

jhodgdon’s picture

OK, actually I feel like procrastinating from other work so I'll fix this today. :)

jhodgdon’s picture

Status: Active » Fixed

Well, that was easy. Sorry for not doing it sooner. I just committed a fix for this to the DEV version of the module. Get now via Git revision control, or it should be in the -dev archive on the project page within 12 hours. Let me know how it works.

mengi’s picture

Well, that was easy. Sorry for not doing it sooner.

No worries, we all have time constraints. I truly appreciate the time you spent working on this module, it is exactly what I needed.

I will test it and report back.

mengi’s picture

Drupal.org finally updated the dev version. I tested it and it works great. Using the responsive Omega theme, the map adjusted as intended. Thanks again!

Status: Fixed » Closed (fixed)

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

massiws’s picture

Thank you for this very simple module!
After install today dev version I can't use values like 100% in Width of embedded map field (and Height also).
Looking in .module file, I see that (int) casting is still there.
This is what I've done:

  // $height = (int) check_plain($display['settings']['iframe_height']);
  // $width = (int) check_plain($display['settings']['iframe_width']);
  $height = check_plain($display['settings']['iframe_height']);
  $width = check_plain($display['settings']['iframe_width']);

As Mark_L6n said, was there any specific reason for using integer casts there?

Thank you.

jhodgdon’s picture

Issue summary: View changes
Status: Closed (fixed) » Needs work

You are correct, and I'm sorry -- somehow the change I made in April for this got reversed. I'll take a look.

jhodgdon’s picture

Status: Needs work » Fixed
StatusFileSize
new2.38 KB

OK, I figured it out.

It turns out that static maps only accept integer widths, in pixels. Dynamic maps use iframes, so they accept any kind of CSS width a browser will understand.

So when the fix for #1790250: Add ability to have a static map went in, the integer cast came back, which was not the right thing to do.

I've made an update, which should be in the next -dev package. For reference, here's a patch.

Status: Fixed » Closed (fixed)

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