Repository navigation
Escape ${ in popup and tooltip text - #2356
Open
KhadeerBasha1232 wants to merge 1 commit into
Open
KhadeerBasha1232 wants to merge 1 commit into
KhadeerBasha1232 wants to merge 1 commit into
Conversation
Popup, Tooltip and ClickForMarker put their text inside a JavaScript
template literal. escape_backticks escaped backslashes and backticks,
but not "${", so text such as "price: ${price}" was evaluated as an
interpolation: the map script stopped with a ReferenceError, and any
expression in the text ran as code. This also happened with
parse_html=True, which is meant to show the text as-is.
Escape "${" as well, so the text is shown exactly as given.
KhadeerBasha1232
temporarily deployed
to
pypi
November 19, 2026 03:41 — with
GitHub Actions
Inactive
This branch was previously deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Escape
${in popup and tooltip textPopup,TooltipandClickForMarkerplace their text inside a JavaScript template literal.escape_backticksescaped backslashes and backticks, but not${, so any${...}in the text was evaluated as an interpolation.Opening
map.htmlthrowsReferenceError: price is not defined, the popup is never bound, and the rest of that script block doesn't run.An expression inside
${...}runs as code. That also happens withparse_html=True, which is meant to show the text as-is:Popup("${console.log(document.domain)}", parse_html=True)logs the page's domain when the map loads. That matters when popup text comes from data, such as a column of names or descriptions.I checked both cases in a browser before and after this change. With the change, the popup shows the text literally (
price: ${price}) and nothing runs.Change
escape_backticksnow also escapes${as\${, so the text is shown exactly as given. A$that isn't followed by{is left alone.Tests
test_escape_backticks: unit cases for backticks, backslashes and${, including\${and$5 and {x}.test_popup_template_literal_interpolation: coversparse_html=Falseandparse_html=True.test_tooltip_template_literal_interpolationThe new tests fail without the change.