Skip to content

Commit b3bc340

Browse files
committed
For the plots.pl macro HTML encode the aria description.
This is to fix an issue reported by @somiaj in openwebwork#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.
1 parent 15c2531 commit b3bc340

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

lib/Plots/JSXGraph.pm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -499,7 +499,7 @@ sub init_graph {
499499
const descriptionSpan = document.createElement('span');
500500
descriptionSpan.id = `\${id}_description`;
501501
descriptionSpan.classList.add('visually-hidden');
502-
descriptionSpan.textContent = '${\($axes->style('aria_description'))}';
502+
descriptionSpan.textContent = ${\(Mojo::JSON::encode_json($axes->style('aria_description')))};
503503
board.containerObj.after(descriptionSpan);
504504
board.containerObj.setAttribute('aria-describedby', descriptionSpan.id);
505505
board.suspendUpdate();

0 commit comments

Comments
 (0)