When using a "Leaflet Map" view, the settings (style options) has an option "Title Field" which has a description "Choose the field which will appear as a title on tooltips. " If we set this value to "Content: Title", then the node titles correctly appear as a popup when hovering over a marker.

However if the node title includes a special character, this gets double html encoded - for example "A & B" comes out as "A & B".

The cause is that LeafletMap::render fetches the rendered field which is already HTML encoded

              $point['label'] = $this->rendered_fields[$id][$this->options['name_field']];

And when the js code eventually sets the title attribute on the image, it naturally/securely HTML encodes the passed string.

So a possible fix is to HTML decode the rendered field. I'm not sure if that's the best fix - maybe someone has a better idea. As far as I can see this is safe because javascript provides the security by HTML encoding again.

Patch coming up.

CommentFileSizeAuthor
#2 leaflet.html-entity-encode-2978612-2.patch906 bytesadamps

Comments

AdamPS created an issue. See original summary.

adamps’s picture

Status: Active » Needs review
StatusFileSize
new906 bytes

  • itamair committed 2585224 on 8.x-1.x authored by AdamPS
    Issue #2978612 by AdamPS: Tooltip titles for marker are double encoded
    
itamair’s picture

Status: Needs review » Fixed

Nice catch @AdamPS, committed to last dev ...

adamps’s picture

Thanks @itamair

Status: Fixed » Closed (fixed)

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