Repository navigation
refactor(editor): render option lists through an escaping helper - #336
Merged
Merged
Conversation
Add wm_editor_attributes() and wm_editor_option() so every attribute value and option label on the editor page is escaped by construction. Attribute names must match a plain HTML name; true renders a boolean attribute and false or null omits it. Values use plugin_weathermap_escape_attr(), which double-encodes, so names such as "A&B.png" round-trip instead of collapsing to "A&B.png". Convert the icon, background, graph template, background sizing and key style lists, and get_fontlist(). The key style labels were previously printed unescaped, and the "Special Icon (AICON)" placeholder lost a stray ">". Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
…ge lists Fail when the editor page concatenates or interpolates an unescaped value into an HTML attribute, or prints an <option> without wm_editor_option(). Render the icon and background lists from real image files with hostile names through the editor page's own code, parse the result with DOMDocument, and check that no attributes or elements are injected and that every value and label round-trips. Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
This was referenced Nov 9, 2026
The option lists now pass __() text to the escaping helper instead of __esc(), so the template's source references change. Regenerating also adds strings the template was already missing. Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
Write each extracted section to a temporary file and include it in the caller's scope, as the page runs it, instead of passing it to eval(). Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
|
Contributor
|
Checked I also tested this with #341 and the editor split in #347. After updating the image-options test loader for the moved functions, the combined browser suite passed. No additional problem found with the escaping changes in these checks. A quick real-browser check of the dropdowns alongside #341 and #347 would be useful; no separate full walkthrough is needed for this PR. |
Member
Author
This was referenced Nov 9, 2026
TheWitness
approved these changes
Nov 11, 2026
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.



Fixes #334
Render the editor's dynamic
<option>lists throughwm_editor_attributes()andwm_editor_option(), so attribute values and labels are always escaped. Attribute names come from a fixed set and are validated.get_fontlist(). Static template HTML is unchanged.plugin_weathermap_escape_attr(), so a name containing&round-trips exactly.html_escape()does not double-encode, so it doesn't.>is gone from the AICON placeholder, and the missing space beforeselectedis restored.Merge order: #341 is stacked on this PR, so merge this one first.