From 8a3816aef0665d018bf296195861281e0afea203 Mon Sep 17 00:00:00 2001 From: nsfisis Date: Tue, 17 Dec 2024 00:17:09 +0900 Subject: fix(blog/nuldoc): encode special characters such as ampersand in quoted attribute values --- vhosts/blog/nuldoc-src/renderers/html.ts | 4 +++- vhosts/blog/nuldoc-src/renderers/xml.ts | 2 +- .../public/posts/2021-10-02/python-unbound-local-error/index.html | 2 +- .../index.html | 6 +++--- vhosts/blog/public/posts/2024-12-04/cohackpp-report/index.html | 2 +- 5 files changed, 9 insertions(+), 7 deletions(-) diff --git a/vhosts/blog/nuldoc-src/renderers/html.ts b/vhosts/blog/nuldoc-src/renderers/html.ts index dee9a0cc..70d097b2 100644 --- a/vhosts/blog/nuldoc-src/renderers/html.ts +++ b/vhosts/blog/nuldoc-src/renderers/html.ts @@ -174,7 +174,9 @@ function elementNodeToHtmlText(e: Element, ctx: Context): string { s += " "; for (let i = 0; i < attributes.length; i++) { const [name, value] = attributes[i]; - s += `${name === "className" ? "class" : name}="${value}"`; + s += `${name === "className" ? "class" : name}="${ + encodeSpecialCharacters(value) + }"`; if (i !== attributes.length - 1) { s += " "; } diff --git a/vhosts/blog/nuldoc-src/renderers/xml.ts b/vhosts/blog/nuldoc-src/renderers/xml.ts index c3293d17..69b8266c 100644 --- a/vhosts/blog/nuldoc-src/renderers/xml.ts +++ b/vhosts/blog/nuldoc-src/renderers/xml.ts @@ -72,7 +72,7 @@ function elementNodeToXmlText(e: Element, ctx: Context): string { s += " "; for (let i = 0; i < attributes.length; i++) { const [name, value] = attributes[i]; - s += `${name}="${value}"`; + s += `${name}="${encodeSpecialCharacters(value)}"`; if (i !== attributes.length - 1) { s += " "; } diff --git a/vhosts/blog/public/posts/2021-10-02/python-unbound-local-error/index.html b/vhosts/blog/public/posts/2021-10-02/python-unbound-local-error/index.html index 8d6743b4..e55a7ac8 100644 --- a/vhosts/blog/public/posts/2021-10-02/python-unbound-local-error/index.html +++ b/vhosts/blog/public/posts/2021-10-02/python-unbound-local-error/index.html @@ -8,7 +8,7 @@ - + diff --git a/vhosts/blog/public/posts/2024-08-19/go-template-access-outer-scope-pipeline-within-with-or-range/index.html b/vhosts/blog/public/posts/2024-08-19/go-template-access-outer-scope-pipeline-within-with-or-range/index.html index 25f47189..da9af0e7 100644 --- a/vhosts/blog/public/posts/2024-08-19/go-template-access-outer-scope-pipeline-within-with-or-range/index.html +++ b/vhosts/blog/public/posts/2024-08-19/go-template-access-outer-scope-pipeline-within-with-or-range/index.html @@ -5,11 +5,11 @@ - + - - + + diff --git a/vhosts/blog/public/posts/2024-12-04/cohackpp-report/index.html b/vhosts/blog/public/posts/2024-12-04/cohackpp-report/index.html index 6d83b669..0eaaf645 100644 --- a/vhosts/blog/public/posts/2024-12-04/cohackpp-report/index.html +++ b/vhosts/blog/public/posts/2024-12-04/cohackpp-report/index.html @@ -8,7 +8,7 @@ - + -- cgit v1.2.3-70-g09d2