Closed (outdated)
Project:
Simple Google Maps
Version:
7.x-1.x-dev
Component:
Code
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
15 Aug 2017 at 00:15 UTC
Updated:
23 Jan 2025 at 16:57 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
jhodgdonThat sounds sensible, thanks! Someone should tell Google that too, because the iframe embedding code was originally taken from what they provide when you go to an address, click the link icon, and choose the "embed" option.
Anyway, if someone wants to make a patch, that would be good... Probably the correct thing to do in the context of this module would be to make the title text configurable, and let the text contain [address] as a token to insert the address.
Comment #3
cboyden commentedThanks, I can start work on a patch. The title attribute of the iframe is announced by screenreaders when navigating to the frame, it won't be visible anywhere. As such it might be hard to concisely explain what the field is for in the field help text, but I'll give it a shot. In case there is more than one of these fields on a page, it would be better to have configurable iframe title text instead of multiple iframes with the same generic title.
Comment #4
jhodgdonSuggested field help text for the configuration:
Title of embedded iframe for screen readers
(or something similar)?
Comment #5
cboyden commentedI've looked at this and I can't come up with a way to make it translatable if the text is potentially going to combine the address placeholder with static text. RTL languages and languages with different sentence syntax make it so you can't easily combine the placeholder with static text in a way that makes sense. How about having a checkbox, where you can choose to use the address text as the iframe title, and if unchecked, you instead get generic title text? That's how Youtube Field ended up handling a similar problem, see #2085749: Iframe missing title tag. It is not entirely clear from the commentary, but if you look at the patch, there is either generic static text or the title of the video, and there's no place where static text is combined with a placeholder or with dynamic text.
Comment #6
jhodgdonI think that's incorrect. The title text would be part of the field configuration, and field configuration values are (at least in principle) translatable, even in Drupal 7 (you might need to use a contributed module to make them translatable).
So the idea would be that in English, you might make ti so that the text is "Map of [address]" and in Spanish that part of the field configuration could be translated to "Mapa de [address]".
Right?
Comment #7
cboyden commentedYou're right, it should be translatable by i18n_field or similar. I've attached a patch that updates the field display settings form, adds a default value, and outputs the title in the template.
Comment #8
dsnopekA teeny, tiny bit of security review :-)
This should go through check_plain() to prevent XSS
This doesn't need check_plain() - the Form API will handle this. I think this could actually lead to double encoding of certain characters
Comment #9
cboyden commentedThanks for the review @dsnopek. In the first case, check_plain is run on $iframe_title before the str_replace, and it's also run on the $address_value before it's substituted in. So the $iframe_title should have been fully checked before it's added to the array.
In the 2nd case, all of the other settings that are strings are also being run through check_plain. I tried putting & and < into the address text, and nothing was double-encoded in the page source.
Comment #10
dsnopekAh, ok, you're right! It's best practice to do filtering as late as possible, so I would have done it when building the render array, but this appears to be totally secure (I just tested it too), so that's fine.
This isn't about the address text, but the "Iframe title" formatter setting. I actually just tested this, and it does get double encoded!
To test in Panopoly, here's some steps to reproduce:
/admin/structure/fieldable-panels-panes/manage/map/display(if not on Panopoly, you can go the "Manage display" page for an entity using the field formatter)<script>alert("xss");</script>in the "Iframe title" fieldGoogle Map of [address] <script>alert("blah")</script>You're right that there's existing code that passing values to '#default_value' through
check_plain(), but those are wrong too. :-) Since that's pre-existing, and not insecure (just buggy), maybe fixing that could be handled in another issue, though?Comment #11
jhodgdonGood catch dsnopek -- let's move that to another issue to fix the other settings, and only make sure the new setting works right on this issue. Thanks!
Sounds like this patch is Needs Work based on #10.
Comment #12
cboyden commentedUpdated patch and interdiff to remove the check_plain function on the new form setting.
Comment #13
dsnopekThe latest patch looks great and addresses my review! Marking as RTBC :-)
Comment #14
jhodgdonThis patch looks pretty good to me! Thanks for the patches and reviews.
But there were a couple of minor things to fix:
a) I wasn't sure about the title/description of the settings field here. In the other settings related to the iframe, we don't use the "iframe" technical term -- iframe_width says "Width of embedded map" etc.
Also I wasn't sure if "Iframe" can be capitalized?
So...
Maybe here we should say something like:
title => 'Title of iframe for embedded map'
description => 'The embedded map is in an iframe HTML tag, which should have a title for screen readers (not shown on the page). Use [address] to insert the address text in the title.'
b) I think this field should go into the settings form nearer the iframe_width and iframe_height settings instead of at the end of the settings.
c) It also needs to be added to the settings summary function.
Comment #15
cboyden commentedThanks for the review @jhodgdon, I've got a new patch and interdiff ready.
Comment #16
jhodgdonThe new patch looks good (at least, the interdiff). I will need to give it a quick test (we have a test script) before committing. Thanks!
Comment #17
jhodgdonFor the double-encoding issue mentioned on #10, I added a separate issue #2913846: Repeated submit of settings form causes problems.
Sorry I haven't tested this yet...
Comment #18
jhodgdonSomeone just filed this duplicate issue but leaving them both as the other is Drupal 8
Comment #19
cboyden commentedUpdated patch to account for changes released in version 1.5.
Comment #20
smustgrave commentedWith D7 officially EOL believe this is out dated, if still valid for 4.0.x please reopen