When setting the source for the tooltip in Leaflet Views, if you choose a text field that allows markup, or if you are rewriting the field's markup in the view, that markup is displayed in the tooltip according to the formatter settings.
Screenshots
Title field, when it's configured to link to its node content:
Body field using the Default formatter (Summary formatter also looks like this):
Body field using the Plain text formatter:
Markup should be stripped from the tooltip text before it's rendered. For Body and other fields that can contain markup themselves, would it be possible to force the formatter to Plain text? What would be a good solution to catch odd cases like simple text fields that are rewritten with markup?
Comment | File | Size | Author |
---|---|---|---|
#25 | leaflet-not-decoding-html-quote-entities-2169197-25.patch | 805 bytes | c7bamford |
#2 | tooltip-strip-after.jpg | 39.14 KB | othermachines |
#2 | tooltip-strip-before.jpg | 44.9 KB | othermachines |
#1 | leaflet-tooltip_does_not_strip_markup-2169197-1.patch | 703 bytes | interdruper |
leaflet-wysiwyg-tooltip.png | 242.6 KB | cboyden |
Comments
Comment #1
interdruper CreditAttribution: interdruper commentedAn easy fix is to filter any html tag in the Javascript code.
Patch attached.
Comment #2
othermachines CreditAttribution: othermachines commentedPatch applies cleanly against 7.x-1.x. Works as advertised.
Before:
After:
Comment #3
xaa CreditAttribution: xaa commentedthere is still the problem for the html tag '
could you adjust the patch, please ?
see http://i.imgur.com/Hhr4UTG.png
Comment #4
ahillio CreditAttribution: ahillio commentedYes patch applies and works. I've used it several times on leaflet-1.1 (haven't tried it on dev).
@xaa are you sure you properly patched the module with this? It's a simple patch so should work I think...
Comment #5
dmegatool CreditAttribution: dmegatool commentedThe apostrophe doesn't work for me either. It shows as ' in the tooltip. Other characters seems ok... Why is this different than the marker tag which works perfectly, without patching the js ?
One thing I noticed, ’ works but not ' (they're different and I need the latter one).
Comment #6
interdruper CreditAttribution: interdruper commentedThe problem here is that the text inside the HTML tags is including html-special characters.
You must previously escape them if you want to get rid of them:
Sorry, I cannot find out a more elegant way to do this.
Comment #7
timodwhit CreditAttribution: timodwhit commentedHave you tried to do something like:
$point['label'] = strip_tags($this->rendered_fields[$id][$this->options['name_field']]);
on line 267 of leaflet_views_plugin_style.inc?I'll post a patch soon
Comment #8
timodwhit CreditAttribution: timodwhit commentedHere is a patch that strips the tags from the view in the formatter
Comment #9
xaa CreditAttribution: xaa commentedthank you for the patch Timodwhit. Unfortunately not working here.
Could you test it dmegatool ?
Comment #10
dmegatool CreditAttribution: dmegatool commentedNot working here either. Still showing
'
Comment #11
hutch CreditAttribution: hutch commentedtry something like
Comment #12
dmegatool CreditAttribution: dmegatool commentedStill not doing it.
Comment #13
xaa CreditAttribution: xaa commentedidem.
Comment #14
interdruper CreditAttribution: interdruper commentedHave you tried modification #6 over patch #1?
Comment #15
timodwhit CreditAttribution: timodwhit commented@hutch's solution worked for me, I did need to clear the cache though: I tried
name ' & "" <>
and it printed out properly... Patch rerolled.Comment #16
xaa CreditAttribution: xaa commentedinterdruper yes I tried #6 over patch #1
Comment #17
yaten CreditAttribution: yaten commentedLeaflet 7.x-1.1 + patch #15 fixed my problem ( " ..039; " became " ' ").
Thanks.
Comment #19
RdeBoerPatch from #14 applied.
Thanks everyone!
Available now in Leaflet 7.x-1.x-dev or 7.x-1.2 and later, once released.
Rik
Comment #20
RdeBoerComment #22
asiby CreditAttribution: asiby commentedHello. I need to revive this issues because as of today, I can confirm that the issue is still present (more than a year after being marked closed). The htmlspecialchars_decode is now being called without the ENT_QUOTES flag and as a result, the default behaviour is to leave quotes alone.
Can the maintainer please reopen it?
Comment #23
asiby CreditAttribution: asiby commentedHere is a patch for it.
Comment #24
RdeBoerRe-opened so it doesn't get forgotten.
Comment #25
c7bamford CreditAttribution: c7bamford commentedPatches should be created from the module's level so that automated builds can use them.