From a605e07ea29bff616fcd3b0ab3f3debc8a3f94a0 Mon Sep 17 00:00:00 2001 From: Shiro Kawai Date: Sun, 24 Mar 2024 21:29:46 -1000 Subject: [PATCH] sxml.tools - Fix to escape attribute values Related: https://github.com/shirok/Gauche-makiki/issues/11 --- ChangeLog | 7 +++++++ ext/sxml/sxml-tools.scm.in | 9 +++++++++ 2 files changed, 16 insertions(+) diff --git a/ChangeLog b/ChangeLog index 2346e64cd..27509d5b0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2024-03-24 Shiro Kawai + + * ext/sxml/sxml-tools.scm.in (sxml:attr->xml, sxml:attr->html): + Override to fix shortcomings of the original sxml that attribute + values are not quoted. + Related: https://github.com/shirok/Gauche-makiki/issues/11 + 2024-03-23 Shiro Kawai * src/gauche-package.in (compile): Support --c++ option. This tells diff --git a/ext/sxml/sxml-tools.scm.in b/ext/sxml/sxml-tools.scm.in index f6cf9cd45..305ca9eea 100644 --- a/ext/sxml/sxml-tools.scm.in +++ b/ext/sxml/sxml-tools.scm.in @@ -100,6 +100,15 @@ ;#include-body "src/sxml-tools.scm" +;; Override these two to emit attribute value properly escaped. +(define (sxml:attr->xml attr) + `(" " ,(sxml:ncname attr) "=\"" ,(sxml:string->xml (cadr attr)) "\"")) +(define (sxml:attr->html attr) + (if (equal? "" (cadr attr)) + `(" " ,(sxml:ncname attr)) + `(" " ,(sxml:ncname attr) "=\"" ,(sxml:string->html (cadr attr)) "\""))) + + ;; Local variables: ;; mode: scheme ;; end: