From b3bc3407fa3718a0eddb73997792c38ab7b8cb32 Mon Sep 17 00:00:00 2001 From: Glenn Rice Date: Sun, 4 Jan 2026 16:43:59 -0500 Subject: [PATCH] For the `plots.pl` macro HTML encode the aria description. This is to fix an issue reported by @somiaj in #1322 in which a apostrophe in the description causes invalid javascript to be generated. This uses `Mojo::JSON::encode_json` to encode the text. That is the same that is used before. --- lib/Plots/JSXGraph.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Plots/JSXGraph.pm b/lib/Plots/JSXGraph.pm index 6b531d861..b6ac48d69 100644 --- a/lib/Plots/JSXGraph.pm +++ b/lib/Plots/JSXGraph.pm @@ -499,7 +499,7 @@ sub init_graph { const descriptionSpan = document.createElement('span'); descriptionSpan.id = `\${id}_description`; descriptionSpan.classList.add('visually-hidden'); - descriptionSpan.textContent = '${\($axes->style('aria_description'))}'; + descriptionSpan.textContent = ${\(Mojo::JSON::encode_json($axes->style('aria_description')))}; board.containerObj.after(descriptionSpan); board.containerObj.setAttribute('aria-describedby', descriptionSpan.id); board.suspendUpdate();