Single Quotes in Marker Popups Break HTML
See original GitHub issuemap_1 = folium.Map(location=[-23.5505, -46.6333],
zoom_start=12)
folium.Marker([-23.550519999999999, -46.633308999999997], popup = 'name').add_to(map_1)
folium.Marker([-23.5505, -46.6333], popup = "name'with'quotes").add_to(map_1)
map_1.save('marker_name_test.html')
Problem description
If a marker popup string contains single quotes, HTML parsing in web browsers breaks and the output HTML file can’t be rendered.
Expected Output
A correctly rendered HTML page with the single quotes properly escaped or stripped from the popup string.
Output of folium.__version__
‘0.5.0’
Issue Analytics
- State:
- Created 6 years ago
- Comments:7 (1 by maintainers)
Top Results From Across the Web
newline in Leaflet marker popup text - Stack Overflow
The HTML inside the popup is receiving a newline character. The problem is that the newline character is being displayed as collapsed whitespace ......
Read more >Single Quote in HTML | PageDart
Does it break your HTML? The answer is, it depends. Single quotes in HTML can break your site. If single quotes are breaking...
Read more >How to insert new line text in popup - GIS Stack Exchange
bindPopup() takes an HTML string as first parameter. If you want your lines to appear on different lines, you need to add the...
Read more >Add multiple links to a popup | Documentation
If you are working directly on the mapdata.js file you'll want to use double quotes (") in your HTML and single quotes (')...
Read more >Adding 'tooltip' popups on maps - Toolset
I think the problem is that I have to use url("image") for the DIV... but the extra quotation marks break your shortcodes. The...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Thanks for the comment @MCOfficer. Thankfully this issue has been fixed as far as I know in #962, which will be in the next release.
seeing this error pop up over and over again on SO, i’d recommend at least printing a warning if the html contains an unescaped single quote.