Skip to content

issue with escaping dictionary keys in send_button_html - #1080

Merged
nonprofittechy merged 3 commits into
mainfrom
fix-1079-javascript-links
Jul 22, 2026
Merged

issue with escaping dictionary keys in send_button_html#1080
nonprofittechy merged 3 commits into
mainfrom
fix-1079-javascript-links

Conversation

@nonprofittechy

@nonprofittechy nonprofittechy commented Jul 19, 2026

Copy link
Copy Markdown
Member

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.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 build javascript: URLs using JSON serialization and HTML attribute escaping.
  • Updated send_email_table_row(), send_button_to_html(), and send_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 rajeswari1301 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@nonprofittechy
nonprofittechy merged commit 5b55a10 into main Jul 22, 2026
8 checks passed
@nonprofittechy
nonprofittechy deleted the fix-1079-javascript-links branch July 22, 2026 01:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

send_button_html (and related methods) do not properly escape DAObject intrinsic names that have a ', like dictionary keys

3 participants