question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Single Quotes in Marker Popups Break HTML

See original GitHub issue
map_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:closed
  • Created 6 years ago
  • Comments:7 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
Conengmocommented, Oct 14, 2018

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.

0reactions
MCOfficercommented, Oct 14, 2018

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found