Repository navigation
Quote Search strings as JSON - #2357
Open
KhadeerBasha1232 wants to merge 1 commit into
Open
KhadeerBasha1232 wants to merge 1 commit into
KhadeerBasha1232 wants to merge 1 commit into
Conversation
Search put search_label, placeholder and position inside single quotes without escaping them, so a value with an apostrophe, such as placeholder="Search for a state's name", produced a JavaScript syntax error and the whole map script failed to run. Render these values with the tojson filter instead.
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.
Quote
Searchstrings as JSONSearchputsearch_label,placeholderandpositioninside single quotes in the generated JavaScript, without escaping them. A value with an apostrophe breaks the script:This renders
textPlaceholder: 'Search for a state's name',, which is aSyntaxError(Unexpected identifier 's'). Nothing in the map script runs, so the page is blank. The same happens for a property name that contains an apostrophe.I checked this in a browser: before the change the page is blank, and after it the map and search box show up with the placeholder
Search for a state's name.Change
These three values are now rendered with the
tojsonfilter, the same waycollapsedalready is.tojsonalso escapes<,>,&and', so the values are safe inside the<script>block.Tests
test_search_quotes_stringschecks thatsearch_labelandplaceholderare rendered as valid JS strings when they contain an apostrophe. It fails without the change.