issue with escaping dictionary keys in send_button_html - #1080
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR addresses Issue #1079 by ensuring that JavaScript href values generated by ALDocumentBundle.send_button_html() (and related “send” button helpers) correctly escape Docassemble intrinsic names that may include ' (e.g., dictionary-key access like foo['bar']), preventing broken HTML/JS when rendered.
Changes:
- Added
_javascript_href()helper to buildjavascript:URLs using JSON serialization and HTML attribute escaping. - Updated
send_email_table_row(),send_button_to_html(), andsend_button_html()to use_javascript_href()instead of manual string concatenation. - Added unit tests verifying escaping behavior and argument type preservation.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| docassemble/AssemblyLine/al_document.py | Introduces _javascript_href() and routes send-button JavaScript URL generation through it to properly escape dictionary-key intrinsic names. |
| docassemble/AssemblyLine/test_al_document.py | Adds targeted unit tests for escaping and for preserving argument types via JSON serialization. |
rajeswari1301
approved these changes
Jul 21, 2026
rajeswari1301
left a comment
Contributor
There was a problem hiding this comment.
Looks good to me. Ran the fix's tests locally (all passing, including the ones for the quote-escaping bug itself), and manually tested send_button_html() - worked cleanly
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.
Fix #1079
A limited fix for issue escaping the intrinsic name of objects to construct the event name for send_button_html. This keeps the JavaScript link construction mostly as-is, except escaping for characters that would break the rendered HTML link.
Perhaps a better long-term fix would be to switch to using a JS listener and adding to the
data-attribute, but this is more appropriate for now.