Repository navigation
Escape strings in VectorGrid, TimestampedGeoJson and FloatImage - #2363
Open
KhadeerBasha1232 wants to merge 1 commit into
Open
KhadeerBasha1232 wants to merge 1 commit into
KhadeerBasha1232 wants to merge 1 commit into
Conversation
Three plugins put user-supplied strings into their templates without escaping: - VectorGridProtobuf put `url` inside single quotes, so a URL with an apostrophe ended the JS string and the layer was never created. - TimestampedGeoJson put `date_options` inside double quotes, so a format with a double quote broke the script and no time control appeared. - FloatImage put `image` into the img src attribute as-is, so a double quote ended the attribute and the rest was parsed as new HTML attributes, such as an onerror handler that runs code. Use tojson for the two JS strings and HTML-escape the src attribute. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
KhadeerBasha1232
temporarily deployed
to
pypi
November 19, 2026 17:28 — 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 strings in VectorGrid, TimestampedGeoJson and FloatImage
Three plugins put user-supplied strings into their templates without escaping. A quote in the value ends the surrounding string and breaks the map, or in the
FloatImagecase adds new HTML attributes. This is the same kind of problem as #2357 (Search).VectorGridProtobufurlwith', e.g....?name=O'Neil'...'; JS syntax error, the layer is never createdTimestampedGeoJsondate_optionswith""..."; JS syntax error, the time control never appearsFloatImageimagewith"src="..."as-is; the rest becomes new attributes on the<img>, sox.png" onerror="..."runs codesrcThe
FloatImagecase matters when the image URL comes from data or user input.Change
vectorgrid_protobuf.py:'{{ this.url }}'→{{ this.url|tojson }}timestamped_geo_json.py:"{{this.date_options}}"→{{ this.date_options|tojson }}float_image.py:src="{{ this.image }}"→src="{{ this.image|e }}"Values without quotes or
&render exactly as before. InFloatImagea&in a URL becomes&, which is the correct form inside an HTML attribute and gives the browser the same URL.Tests
test_vectorgrid_url_with_quotetest_timestamped_geo_json_date_options_with_quotestest_float_image_escapes_srctest_timestamped_geo_jsonto match.The new tests fail without the change. I also opened the generated maps in a browser before and after the change, with the values from the table. Before, the VectorGrid layer and the time control were missing, and the
onerrorhandler in theFloatImagepage ran. After, all three maps work and nothing extra runs.